python爬虫
import re
import urllib.request
headers=(“User-Agent”,“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36”)
opener=urllib.request.build_opener()
opener.addheaders=[headers]
data=opener.open(“http://qiushibaike.com/").read()
print(len(data))
urllib.request.install_opener(opener)
data=urllib.request.urlopen(“http://qiushibaike.com").read().decode(“utf-8”,“ignore”)
print(len(data))
pat=**”
**rst=re.compile(pat,re.S).findall(data)
print(rst)
python爬虫
http://example.com/python爬虫.html