Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If you pass in an object with a regular expression, Beautiful Soup will filter the results according to that regular expression using its search() method. The following code finds all tags whose names start with the letter "b"; in our case, these are the body and b tags:
import re
for tag in soup.find_all(re.compile("^b")):
print(tag.name)
# body
# b
for tag in soup.find_all(re.compile("t")):
print(tag.name)
# html
# title
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question