为了账号安全,请及时绑定邮箱和手机立即绑定

Python:re.findall 不会在 html 中找到字符串

Python:re.findall 不会在 html 中找到字符串

郎朗坤 2021-09-28 14:59:57
re.findall 不会在 html 中找到字符串。这是我的代码:def get_id(html_source):    the_button = re.findall("preview.aspx?id=1692003076", html_source)    print(the_button)当我print(html_source)得到 html 时,可以看到它包含“preview.aspx?id=1692003076”。re.search 也未能找到该字符串。我的代码中有另一个 re.findall ,它工作正常:id_matches = re.findall('<input type="checkbox" id="\d+"', html_source)知道为什么它不起作用吗?
查看完整描述

1 回答

?
千万里不及你

TA贡献1784条经验 获得超9个赞

注意“?” 是正则表达式中的特殊字符。你需要逃避它。


查看完整回答
反对 回复 2021-09-28
  • 1 回答
  • 0 关注
  • 251 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号