r语言python print包_python : 批量下载R语言库包
soupR.py 代碼如下# -*- coding: cp936 -*-
import urllib
import urllib2
import os, re
from BeautifulSoup import BeautifulSoup
localDir = 'D:/test/'
URL = "外鏈網址已屏蔽;
page = urllib2.urlopen(URL)
soup = BeautifulSoup(page)
page.close()
for a in soup.findAll('a'):
if a is not None:
text = a.text.strip()
#if re.search('map',text):
if text.startswith('map'):
href = a.get('href')
if href.endswith('.zip'):
#print href
localFile = localDir + text
if os.path.exists(localFile):
print localFile,'is exists'
else:
try:
# 按照url進行下載文件,并保存到本地目錄
urllib.urlretrieve(URL+href,localFile)
print href,'is download'
except Exception,e:
continue
總結
以上是生活随笔為你收集整理的r语言python print包_python : 批量下载R语言库包的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 易语言关闭指定窗口_易语言取外部程序指定
- 下一篇: python第七关再来一盘_7、 Pyt