qq_32492073 2018-04-01 03:20 采纳率: 0%
浏览 871
已结题

”房星网 昆明”网原代码如<p>83200元/m2</p>爬取该标签内容为空?

请各位老师帮忙解决,谢谢!我的代码为:
from urllib import request
import re

url = 'https://www.fangstar.com/ershoufang/panlongqu'
root = '

'
unit_price = '

(\d*?元/m.\b)

'

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)

  • 写回答

1条回答 默认 最新

  • threenewbee 2018-04-01 05:18
    关注
     unit_price = '<p>(\d*?元/m.\\b)</p>' 
    这里面<>都需要转义。而且..\\b这个是什么鬼。
    
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作