其他分享
首页 > 其他分享> > 2021年度小说排行榜

2021年度小说排行榜

作者:互联网

"""

姓名 :赵康乐

职业 :学生

日期 :2022-2-8

任务 :爬取2022年度小说排行榜

"""

import requests
from bs4 import BeautifulSoup
url = "https://www.xbiquge.la/paihangbang/"
headers = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0"
}
response = requests.get(url,headers).text
# print(response)
soup = BeautifulSoup(response,"lxml")
for i in range(1,5):
content = soup.find("div",class_="box b"+str(i))
lis = content.find_all("li")
for li in lis:
title = li.a.text
new_url = li.a["href"]
print(title,new_url)

标签:soup,url,find,li,排行榜,2021,年度,response,96.0
来源: https://www.cnblogs.com/zhaokangle/p/15873040.html