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 -

php - Laravel not returning controller -

c# - Confused on how to specify a Platform and Version while using ChromeOptions for RemoteWebDriver with Selenium donNet since recent updates -