import requests
import bs4
import pandas as pd
def l():
for i in range(30):
dict={}
book = soup.find_all('a', attrs={'class': 'jt'})[i].text
sign = soup.find_all('td', attrs={'class': 'td1'})[i].text
the_new_chapter = soup.find_all('td', attrs={'class': 'td6'})[i].text
dict['名称']=book
dict['作者']=the_new_chapter
li.append(dict)
if __name__ == '__main__':
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'}
base_url = 'https://www.17k.com/all/book/2_29_179_0_0_0_0_0_'
li=[]
for i in range(10):
data='{parame}.html'.format(parame=i)
url=base_url+data
# # print(url)
response = requests.get(url=url, headers=headers)
# 获得网页html代码
response.encoding = 'utf-8'
# print(response.text)
soup = bs4.BeautifulSoup(response.text, 'html.parser')
l()
df = pd.DataFrame(li)
print(df)
df.to_excel('linz.xls')