国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python使用心得之獲得github代碼庫列表

2019-11-25 18:21:47
字體:
供稿:網(wǎng)友

1.背景

項(xiàng)目需求,要求獲得github的repo的api,以便可以提取repo的數(shù)據(jù)進(jìn)行分析。研究了一天,終于解決了這個(gè)問題,雖然效率還是比較低下。

因?yàn)間ithub的那個(gè)顯示repo的api,列出了每個(gè)repo的詳細(xì)信息,而且是json格式的。現(xiàn)在貌似還沒有找到可以分析多個(gè)json格式數(shù)據(jù)的方法,所以用的是比較蠢得splite加re的方法。如果大家有更好的方法,不發(fā)留言討論!

2.代碼

import reimport osdef GetUrl(num): str = os.popen("curl -G https://api.github.com/repositories?since=%d"%(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 textif __name__=='__main__': GetUrl(1000)

    其中num的值指的是頁面的id,我們可以做一個(gè)循環(huán),不斷增大num的值,就可以無限提取repo。因?yàn)間ithub的api對(duì)于流量是有限制的,所以這么做是一個(gè)可行的方法。

效果如下(提取下來的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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 调兵山市| 抚顺市| 娄烦县| 天气| 南阳市| 汉沽区| 临泉县| 贡山| 志丹县| 凭祥市| 全椒县| 灵川县| 阳高县| 绥棱县| 息烽县| 永修县| 芦山县| 施甸县| 永清县| 阜南县| 广西| 琼结县| 子洲县| 黔西县| 合阳县| 平果县| 东源县| 巴彦淖尔市| 绍兴市| 锦屏县| 宝丰县| 延长县| 秦皇岛市| 瑞金市| 贡嘎县| 北海市| 宜春市| 日喀则市| 济宁市| 南木林县| 乐安县|