beautifulsoup - python - bs4 grab only certain links -



beautifulsoup - python - bs4 grab only certain links -

<a title="dynamic link" href="test.php">text</a>

how can grab ones have title tag illustration above?

you can utilize select method commonly-used css selector:

>>> bs4 import beautifulsoup >>> html = ''' ... <html> ... <body> ... <a title="dynamic link" href="test1.php">text</a> ... <a href="test2.php">text</a> ... </body> ... </html> ... ''' >>> soup = beautifulsoup(html) >>> soup.select('a[title]') [<a href="test1.php" title="dynamic link">text</a>]

python beautifulsoup

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -