Beautiful Soup if Class “Contains” or Regex?

后端 未结 3 767
离开以前
离开以前 2020-12-05 10:46

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
         


        
3条回答
  •  醉话见心
    2020-12-05 11:03

    Yu can try this:

    regex = re.compile('.*listing-col-.*')
    for EachPart in soup.find_all("div", {"class" : regex}):
            print EachPart.get_text()
    

提交回复
热议问题