2021年度小说排行榜

2022/2/8 23:20:46

本文主要是介绍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)


这篇关于2021年度小说排行榜的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程