My html page has:
...
<table class="t1" ..>
<tr><td> ... <a href="">...</a> ... <a href="">..</a>
</table>
...
I have:
html = BeautifulSoup(page)
links = html.findAll('a', ?????????)
How can I find all links that are inside this table?
Find the table (by class in this case), then find all the links within it.
html = BeautifulSoup(page)
table = html.find('table', 't1')
links = table.findAll('a')
More efficient than a raw find, use SoupStrainer:
html = BeautifulSoup(page, parseOnlyThese=SoupStrainer('table', 't1' ) )
links = html.findAll('a')
See also, the Search by Class documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With