|
上次发了个帖,名字为爬取freebuf个人收藏所有文章并保存到本地python脚本,地址为https://www.chinabaiker.com/thread-2672-1-1.html
然后90sec 的 @火柴人 坛友说想要下载github fork的代码,说fork太多了
运行如图
那么代码来了- #coding = utf-8
- import requests
- import re
- import urllib
- page = range(1,5)
- github_username = raw_input('github_username:')
- for pg in page:
- url = 'https://github.com/%s?page=%s&tab=repositories' %(github_username,pg)
- get = requests.get(url)
- regex = '\<a href="/(.*?)" itemprop\="name codeRepository"\>'
- key = re.findall(regex,get.content)
- for k in key:
- #print k
- url2 = 'https://github.com/'
- xiangmu_name = url2 + k
- print xiangmu_name
- url3 = '/archive/master.zip'
- download = xiangmu_name + url3
- print download
- filename = urllib.urlopen(download)
- info = filename.info()
- filename_regex = 'Content-Disposition: attachment; filename=(.*)'
- filename_down = re.findall(filename_regex,str(info))
- #print filename_down
- for filename1 in filename_down:
- print filename1
- filename2 = filename1.strip()
- urllib.urlretrieve(download,filename2)
复制代码
github地址https://github.com/Jumbo-WJB/spi ... wn_github_master.py
|
|