If the names of my classes are constantly different, say, for example:
listing-col-line-3-11 dpt 41 listing-col-block-1-22 dpt 41 listing-col-line-4-13 CWK 12
Usually I could do:
for EachPart in soup.find_all("div", {"class" : "ClassNamesHere"}): print EachPart.get_text()
There are too many class names to work here, so there arenβt enough of them.
I know that Python does not have ".contains", which I usually used, but it has "in". Although I could not develop a way to enable this.
I hope to find a way to do this with regex. Although again my Python syntax does fail me, I am trying to change the options:
regex = re.compile('.*listing-col-.*') for EachPart in soup.find_all(regex):
But that doesn't sound like a trick.
source share