python获取网页精准爬取数据
import re
import urllib.request
string='<div class="name">(.*?)</div>'
huo=urllib.request.urlopen("https://read.douban.com/provider/all").read()
huo=huo.decode("utf-8")
huo1=re.compile(string).findall(str(huo))
hom=open('D:\hom.txt','w')
hom.write(str(huo1))
hom.close()
简单易了