利用爬虫爬取网页数据
import re
import requests
a=int(input('请输入起始页码'))
b=int(input('请输入结束页码'))
for page in range(a,b):
url=f'http://www.netbian.com/index_{page}.htm'
headers={
'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.36 Edg/122.0.0.0'
}
response=requests.get(url=url,headers=headers)
response.encoding=response.apparent_encoding