1.背景
项目需求,要求获得github的repo的api,以便可以提取repo的数据进行分析。研究了一天,终于解决了这个问题,虽然效率还是比较低下。
因为github的那个显示repo的api,列出了每个repo的详细信息,而且是json格式的。现在貌似还没有找到可以分析多个json格式数据的方法,所以用的是比较蠢得splite加re的方法。如果大家有更好的方法,不发留言讨论!
2.代码
import re import os def GetUrl(num): str = os.popen("curl -G https://api.github.com/repositories"%(num)).read() pattern = '"url"' pattern1='repos' urls=str.split(',\n') for i in urls: if pattern in i and pattern1 in i: # text1=i.splite(':') text=re.compile('"(.*"').findall(i)[1] print text if __name__=='__main__': GetUrl(1000)
其中num的值指的是页面的id,我们可以做一个循环,不断增大num的值,就可以无限提取repo。因为github的api对于流量是有限制的,所以这么做是一个可行的方法。
效果如下(提取下来的repo的api地址):
https://api.github.com/repos/wycats/merb-core
https://api.github.com/repos/rubinius/rubinius
https://api.github.com/repos/mojombo/god
https://api.github.com/repos/vanpelt/jsawesome
https://api.github.com/repos/wycats/jspec
https://api.github.com/repos/defunkt/exception_logger
https://api.github.com/repos/defunkt/ambition
https://api.github.com/repos/technoweenie/restful-authentication
https://api.github.com/repos/technoweenie/attachment_fu
https://api.github.com/repos/topfunky/bong
https://api.github.com/repos/Caged/microsis
https://api.github.com/repos/anotherjesse/s3
https://api.github.com/repos/anotherjesse/taboo
https://api.github.com/repos/anotherjesse/foxtracs
https://api.github.com/repos/anotherjesse/fotomatic
https://api.github.com/repos/mojombo/glowstick
https://api.github.com/repos/defunkt/starling
https://api.github.com/repos/wycats/merb-more
https://api.github.com/repos/macournoyer/thin
https://api.github.com/repos/jamesgolick/resource_controller
https://api.github.com/repos/jamesgolick/markaby
https://api.github.com/repos/jamesgolick/enum_field
https://api.github.com/repos/defunkt/subtlety
https://api.github.com/repos/defunkt/zippy
https://api.github.com/repos/defunkt/cache_fu
https://api.github.com/repos/KirinDave/phosphor
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 【雨果唱片】中国管弦乐《鹿回头》WAV
- APM亚流新世代《一起冒险》[FLAC/分轨][106.77MB]
- 崔健《飞狗》律冻文化[WAV+CUE][1.1G]
- 罗志祥《舞状元 (Explicit)》[320K/MP3][66.77MB]
- 尤雅.1997-幽雅精粹2CD【南方】【WAV+CUE】
- 张惠妹.2007-STAR(引进版)【EMI百代】【WAV+CUE】
- 群星.2008-LOVE情歌集VOL.8【正东】【WAV+CUE】
- 罗志祥《舞状元 (Explicit)》[FLAC/分轨][360.76MB]
- Tank《我不伟大,至少我能改变我。》[320K/MP3][160.41MB]
- Tank《我不伟大,至少我能改变我。》[FLAC/分轨][236.89MB]
- CD圣经推荐-夏韶声《谙2》SACD-ISO
- 钟镇涛-《百分百钟镇涛》首批限量版SACD-ISO
- 群星《继续微笑致敬许冠杰》[低速原抓WAV+CUE]
- 潘秀琼.2003-国语难忘金曲珍藏集【皇星全音】【WAV+CUE】
- 林东松.1997-2039玫瑰事件【宝丽金】【WAV+CUE】