zoukankan      html  css  js  c++  java
  • python 弄github代码库列表

    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?since=%d"%(num)).read()
        pattern = '"url"'
        pattern1='repos'
        urls=str.split(',
    ')         
        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


       

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    微信小程序页面标签中无法使用的js语法
    React-Native真机调试
    微信小程序button设置宽度无效
    CSS禁止选中文本
    vue之 ref 和$refs的使用
    scrapy之 Spider Middleware(爬虫中间件)
    kafka
    Linux select、poll和epoll
    C/C++ 在一个一维数组中查找两个数,使得它们之和等于给定的某个值
    C/C++ 求浮点数平方根
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/4852645.html
Copyright © 2011-2022 走看看