Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping "[" in css selector beatifulsoup python

This is my input:

input autocomplete="off" id="one-step-full-name" name="user[name]"

When I try:

BeautifulSoup.select('input[name=user\[name\]]')

I get:

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 ver 4.6.0

What's wrong with the escaping?


1 Answers

In the 606 line of the element.py:

r'=?"?(?P<value>[^\]"]*)"?\]$'

The right bracket symbol(]) cannot exist in double quotes("").

you can try:

'input[name*=\\"user\[name]'
like image 103
Ming_9527 Avatar answered Apr 21 '26 22:04

Ming_9527



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!