Skip to content
Advertisement

How to find tag with particular text with Beautiful Soup?

How to find text I am looking for in the following HTML (line breaks marked with n)?

JavaScript

The code below returns first found value, so I need to filter by "Fixed text:" somehow.

JavaScript

UPDATE: If I use the following code:

JavaScript

then it returns just Fixed text:, not the <strong>-highlighted text in that same element.

Advertisement

Answer

You can pass a regular expression to the text parameter of findAll, like so:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement