import requests
import re
import os
file_name='小说//'
if not os.path.exists(file_name):
os.mkdir(file_name)
headers={'User_Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 Edg/96.0.1054.53'}
response=requests.get('https://www.52bqg.net/110_110102/',headers=headers)
print(response.text)
html_date=re.findall('
print(html_title)
print(html_data)
i=0
for book_url in html_date:
book_url='https://www.52bqg.net/110_110102/'+book_url+'.html'
# print(book_url)
book_response=requests.get(url=book_url,headers=headers)
# print(book_response.text)
boo_data=re.findall('
(.*?)
',book_response.text)#print(boo_data)
book=re.sub('[( )(
;;;;)(
;;;;)]','',boo_data[0])#替换乱码
# print(book)
with open(file_name+html_title[i]+'.txt','w')as f:
f.write(book)
i=i+1
print(html_title)