beautifulSoup 4.1

Denis McMahon denismfmcmahon at gmail.com
Fri Mar 20 03:23:22 EDT 2015


On Thu, 19 Mar 2015 21:20:30 -0700, Sayth Renshaw wrote:

> But how can I get the value of the following td

# find all tds with a class attribute of "abbreviation"

abbtds = soup.find_all("td", attrs={"class": "abbreviation"})

# display the text of each abbtd with the text of the next td

for td in abbtds:

    print td.get_text(), td.find_next_sibling().get_text()

This works for the html fragment example given, once I fixed it up by 
removing the extra <tr> at the end.

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list