首页 > 代码库 > python : 批量下载R语言库包

python : 批量下载R语言库包

soupR.py 代码如下

# -*- coding: cp936 -*-
import urllib
import urllib2
import os, re
from BeautifulSoup import BeautifulSoup

localDir = 'D:/test/'
URL = "http://cran.dataguru.cn/bin/windows/contrib/3.1/"
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 = http://www.mamicode.com/a.get('href')>


python : 批量下载R语言库包