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
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 华少翌.2005-华少翌【中唱艺能】【WAV+CUE】
- 群星《十二女声Ⅱ》[WAV/CUE/分轨][527MB]
- 大自然音乐系列《漫步在山裡》[WAV/CUE/分轨][502.8MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]
- 史依弘《史依弘交响乐京剧演唱专辑HQ》头版限量编号[WAV+CUE]
- 曼丽2020《女人三十风继续吹》HQCD[WAV+CUE]
- 曼丽2021《女人三十2雾之恋》HQCD[WAV+CUE]
- 隔壁老樊.2019-我曾【好听音乐】【FLAC分轨】
- 高林生.1993-牵挂你的人是我【白天鹅】【WAV+CUE】
- 洪卓立.2012-找个懂我的女孩(国专)【英皇娱乐】【WAV+CUE】
- 曼丽2022《女人三十3晚秋》HQCD[WAV+CUE]
- 曼丽2018《女人三十4冬天》HQCD[WAV+CUE]
- 柏菲-《好歌30年壹》限量开盘母带ORMCD[低速原抓WAV+CUE]
- 大自然音乐系列《水舞》[WAV/CUE/分轨][424.3MB]
- 大自然音乐系列《星光夜语》[WAV/CUE/分轨][453.3MB]