I would like to search for a particular tag by it’s text contents. For example:
<a href="http://goinghere.com">Lets go somewhere</a>
I want to find the above by searching for the text ‘Lets go somewhere’.
I am currently doing it using re. Can it be done in BeautifulSoup or is it better to use re in this case?
You can also use regex.
Using BeautifulSoup to find a HTML tag that contains certain text
Edit: While the find method prints a string if you use it on the command line, that’s actually just a representation of the object it returns; you can access the parent attribute on it to access its BeautifulSoup tag object.