Reputation: 21
I am trying to extract elements from multiple pages using beautifulsoup. However I observed for same element, class value changes on different pages. Although value is same mostly but some part is suffixed at end. Is there way I can search a part of class value like contains function works.
E1 soup.find('div',{'class':'pv-entity__summary-info pv-ent`enter code here`ity__summary-info--background-section'})
E2 soup.find('div',{'class':'pv-entity__summary-info pv-entity__summary-info--background-section mb2'})
Upvotes: 0
Views: 43
Reputation: 501
Assuming that the class name starts with "pv-entity".you can use Regular Expression
soup.find('div',{'class':re.compile(r'pv-entity')})
Upvotes: 1