共计 5194 个字符,预计需要花费 13 分钟才能阅读完成。
def qzzhrb():
"""全站综合热榜"""
headers1={
'Host': 'blog.csdn.net',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36',
}
for y in range(0,4):
time.sleep(5)
response=requests.get(“https://blog.csdn.net/phoenix/web/blog/hotRank?page=”+str(y)+”&pageSize=25”,headers=headers1)
if response.json()["message"]=="success":
for i in response.json()["data"]:
for j in range(1,len(i["articleDetailUrl"])):
if i["articleDetailUrl"][-j]=="/":
articleId=i["articleDetailUrl"][-j+1:]
if select_is_insert(articleId)!=1:
insert_article(articleId,i[“articleDetailUrl”],i[“articleTitle”],i[“nickName”],i[“hotRankScore”])
break
break
1 到 2 天执行一次
def lynrb():
"""畛域内容榜"""
headers1={
'Host': 'blog.csdn.net',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36',
}
list=["python","java","javascript","人工智能","php","c%2Fc%2B%2B","大数据","挪动开发","数据结构与算法","游戏","网络","运维","测试"]
for y in range(0,2):
for i in list:
response=requests.get(“https://blog.csdn.net/phoenix/web/blog/hotRank?page=”+str(y)+”&pageSize=25&child_channel=”+i,headers=headers1)
time.sleep(5)
if response.json()["message"]=="success":
for i in response.json()["data"]:
for j in range(1,len(i["articleDetailUrl"])):
if i["articleDetailUrl"][-j]=="/":
articleId=i["articleDetailUrl"][-j+1:]
if select_is_insert(articleId)!=1:
insert_article(articleId,i[“articleDetailUrl”],i[“articleTitle”],i[“nickName”],i[“hotRankScore”])
break
break
lynrb()
每天 8 点一次
def xjzzb():
"""新晋作者榜"""
headers1={
'Host': 'blog.csdn.net',
'Content-Type': [Skrill 下载](https://www.gendan5.com/wallet/Skrill.html)'application/x-www-form-urlencoded; charset=UTF-8',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36',
}
for y in range(0,5):
time.sleep(5)
response=requests.get(“https://blog.csdn.net/phoenix/web/blog/newUserRank?page=”+str(y)+”&pageSize=20”,headers=headers1)
if response.json()["message"]=="success":
for i in response.json()["data"]:
for j in range(1,len(i["articleDetailUrl"])):
if i["articleDetailUrl"][-j]=="/":
articleId=i["articleDetailUrl"][-j+1:]
if select_is_insert(articleId)!=1:
insert_article(articleId,i[“articleDetailUrl”],i[“articleTitle”],i[“nickName”],i[“hotRankScore”])
break
break
xjzzb()
def recommend():
"""举荐栏目"""
header={
"path": "/api/articles?type=more&category=home&shown_offset=0",
"accept-language": "zh-CN,zh;q=0.9",
"referer": "https://blog.csdn.net/",
"accept": "application/json, text/javascript, */*; q=0.01",
"X - Tingyun - Id": "im - pGljNfnc;r = 332305116",
"Sec - Fetch - Site": "same - origin",
"Sec - Fetch - Mode": "cors",
"Sec - Fetch - Dest": "empty",
"Accept - Encoding": "gzip, deflate, br",
"Accept - Language": "zh - CN, zh;q = 0.9",
"Host": "blog.csdn.net",
"Connection": "keep - alive",
"sec - ch - ua": '"Not A;Brand";v = "99", "Chromium";v = "90", "Google Chrome";v = "90"',
"Accept": "application / json, text / javascript, * / *; q = 0.01",
"X - Requested - With": "XMLHttpRequest",
"sec - ch - ua - mobile": "?0",
"Cookie": "uuid_tt_dd=10_30743904980-1618379395370-717724; Hm_up_6bcd52f51e9b3dce32bec4a3997715ac=%7B%22islogin%22%3A%7B%22value%22%3A%220%22%2C%22scope%22%3A1%7D%2C%22isonline%22%3A%7B%22value%22%3A%220%22%2C%22scope%22%3A1%7D%2C%22isvip%22%3A%7B%22value%22%3A%220%22%2C%22scope%22%3A1%7D%7D; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_30743904980-1618379395370-717724; __gads=ID=e49a2afa774ef751-22e5578266c70052:T=1618379398:RT=1618379398:S=ALNI_MbGqjNddCmz_vAd5NE9aUuroCHdwA; ssxmod_itna=YqGxcCD=0QK7qYKGHEoQ40OxUxmufqLLdr80i44GNYWDZDiqAPGhDCbbtxw0mBmDI=fijYav4j4biaPIoKQmOXxbDCPGnDB9+fpDem=D5xGoDPxDeDADYo6DAqiOD7T=DEDm48DaxDoDehI7DY5DhxDC0GPDwx0CAg04eG9s7=7Cd/94VxxeAxG1=40HKYSm5t8EeGv3+x0kU40OuP58U6YDU7b4fQioWhhedndeklTYlelK/SD46nuKiD+xoehrTnq9DDpXbm6DD===; ssxmod_itna2=YqGxcCD=0QK7qYKGHEoQ40OxUxmufqLLdr80DA=nxAeD/FCbDFx48kIZp7KAphO1Cx25eGozrjvh8kC2L5tYKCxjy+INZxC0+h/0tZMc8qC2CO=5aZgAKKHnShO94Y8V=uoW+9KyHY/zkQG8xX4HqLlUDNjK0QxOW0x9EYc0wYQixG2Y0PDFqD2YiD==; dc_session_id=10_1620356271093.957181; TY_SESSION_ID=0fae6181-358c-443f-9ab9-19d622159650; dc_sid=dcd3c87e76fb26c5661211133000d30c; c_first_ref=default; c_first_page=https%3A//blog.csdn.net/; c_segment=12; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1618379397,1619322330,1620356273; c_ref=https%3A//blog.csdn.net/; firstDie=1; log_Id_view=51; c_pref=https%3A//blog.csdn.net/; c_page_id=default; dc_tos=qspx78; log_Id_pv=10; c-login-auto=9; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1620359253; announcement-new=%7B%22isLogin%22%3Afalse%2C%22announcementUrl%22%3A%22https%3A%2F%2Fblog.csdn.net%2Fblogdevteam%2Farticle%2Fdetails%2F112280974%3Futm_source%3Dgonggao_0107%22%2C%22announcementCount%22%3A0%7D",
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36"
}
list=[“python”,”home”,”career”,”java”,”web”,”arch”,”blockchain”,”db”,”5g”,”game”,”mobile”,”ops”,”sec”,”engineering”]
for i in list:
response=requests.get(“https://blog.csdn.net/api/articles?type=more&category=%s&shown_offset=0″%i,headers=header)
if response.json()["status"]=="true":
for i in response.json()["articles"]:
if select_is_insert(i["product_id"]) != 1:
insert_article(i["product_id"],i["url"],i["title"],i["nickname"],i["views"])