I have this:
dates = soup.findAll("div", {"id" : "date"})
However, I need id to be a wildcard search since the id can be date_1, date_2 etc.
You can provide a callable as a filter:
dates = soup.findAll("div", {"id" : lambda L: L and L.startswith('date')})
Or as @DSM points out
dates = soup.findAll("div", {"id" : re.compile('date.*')})
as BeautifulSoup will recognise a RegExp object and call its .match() method.
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