There are two div tags on the page - <div class="r 1"> and <div class="r"> This code

 html = BeautifulSoup(s, 'lxml') print(html.find('div', {'class': 'r 1'}).get_text()) print(html.find('div', {'class': 'r'}).get_text()) 

in both cases it finds <div class="r 1"> . How to get the <div class="r"> ?

  • html.find_all ('div', {'class': 'r'}). get_text () The find method returns the first value found - fedotsoldier

0