How would I, using BeautifulSoup, search for tags containing ONLY the attributes I search for?
For example, I want to find all
You can use
lambda
functions in findAll
as explained in documentation. So that in your case to search for td
tag with only valign = "top"
use following:td_tag_list = soup.findAll(
lambda tag:tag.name == "td" and
len(tag.attrs) == 1 and
tag["valign"] == "top")