from urllib import request
import re
url = 'https://www.fangstar.com/ershoufang/panlongqu'
root = '<div class="info"([\s\S]*?)</div>'
unit_price = '<p>(\d*?元/m.\\b)</p>'
r = request.urlopen(url)
htmls = r.read()
htmls = str(htmls,encoding = 'utf-8')
root_html = re.findall(root,htmls)#root:根
ershous = []
for html in root_html:
unit_price = re.findall(unit_price,html)
ershou = {'unit_price':unit_price}
ershous.append(ershou)
print(ershous)
添加回答
举报
0/150
提交
取消