If my class names 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 >
listing-col-line-3-11 dpt 41 listing-col-block-1-22 dpt 41 listing-col-line-4-13 CWK 12
You could avoid regex by using partial matching with gazpacho...
Input:
html = """\ A B C """
Partial matching code:
from gazpacho import Soup soup = Soup(html) divs = soup.find("div", {"class": "listing-col-"}, partial=True) [div.text for div in divs]
Output:
['A', 'B', 'C']