爬取github上流行的python项目

时间:2022-10-13 20:10:36
# -*- coding:utf-8 -*-
__author__ = "MuT6 Sch01aR" import requests
from pyquery import PyQuery def GetGitHub():
url = "https://github.com/trending/python"
r = requests.get(url)
for i in PyQuery(r.content)(".repo-list>li"):
repo_url = "https://github.com"+PyQuery(i).find(".mb-1 a").attr("href")
name = PyQuery(i).find(".mb-1 a").text()
star = PyQuery(i).find("a.mr-3").text()
print("项目:"+name,"星星数:"+star,"项目地址:"+repo_url)
GetGitHub()

运行结果

爬取github上流行的python项目