1. 程式人生 > >python獲取網頁精準爬取數據

python獲取網頁精準爬取數據

imp url pil 簡單 vid req pen pro utf

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()

簡單易了

python獲取網頁精準爬取數據