import requests
from bs4 import BeautifulSoup
def get_book():
re=requests.get(url,headers=headers)
soup=BeautifulSoup(re.text,'html.parser')
for i in range(1,21):
title=soup.select(f'#book-img-text > ul > li:nth-child({i}) > div.book-mid-info > h2 > a')[0].text
introduction=soup.select(f'#book-img-text > ul > li:nth-child({i}) > div.book-mid-info > p.intro')[0].text
author=soup.select(f'#book-img-text > ul > li:nth-child({i}) > div.book-mid-info > p.author > a.name')[0].text
category=soup.select(f'#book-img-text > ul > li:nth-child({i}) > div.book-mid-info > p.author > a.go-sub-type')[0].text
print(f'{i+num}. {title}\t作者:{author}\t{category}\n{introduction}')
print('----------------------------------')
if __name__ == '__main__':
爬取起点推荐总榜前200本(requests)
最新推荐文章于 2024-04-16 18:50:17 发布