日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

python 获得github代码库列表

發(fā)布時間:2025/4/5 python 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 获得github代码库列表 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.背景

項目需求,要求獲得github的repo的api,以便可以提取repo的數(shù)據(jù)進行分析。研究了一天,終于解決了這個問題,雖然效率還是比較低下。 ? ? 因為github的那個顯示repo的api,列出了每個repo的詳細信息,而且是json格式的。現(xiàn)在貌似還沒有找到可以分析多個json格式數(shù)據(jù)的方法,所以用的是比較蠢得splite加re的方法。如果大家有更好的方法,不發(fā)留言討論! ??

2.代碼

import re import 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,我們可以做一個循環(huán),不斷增大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


???

總結(jié)

以上是生活随笔為你收集整理的python 获得github代码库列表的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。