【发布时间】:2018-02-21 13:05:53
【问题描述】:
这是我的输入:
input autocomplete="off" id="one-step-full-name" name="user[name]"
当我尝试时:
BeautifulSoup.select('input[name=user\[name\]]')
我明白了:
lib\site-packages\bs4\element.py", line 1477, in select 'Unsupported or invalid CSS selector: "%s"' % token) ValueError: Unsupported or invalid CSS selector: "input[name=user[name]]"
BeatifulSoup 4.6.0 版
转义有什么问题?
【问题讨论】:
-
不熟悉 BeautifulSoup,但您可以尝试使用违规字符的十六进制代码进行转义。
'input[name=user\5Bname\5D]'
标签: python css beautifulsoup escaping selector