How to get data from all pages in Github API with Python?

前端 未结 6 2051
借酒劲吻你
借酒劲吻你 2021-02-05 17:55

I\'m trying to export a repo list and it always returns me information about the 1rst page. I could extend the number of items per page using URL+\"?per_page=100\" but it\'s not

6条回答
  •  走了就别回头了
    2021-02-05 18:52

            link = res.headers.get('link', None)
    
            if link is not None:
                link_next = [l for l in link.split(',') if 'rel="next"' in l]
                if len(link_next) > 0:
                    return int(link_next[0][link_next[0].find("page=")+5:link_next[0].find(">")])
    

提交回复
热议问题