import requests
from bs4 import BeautifulSoup as bs
url = "https://www.yelp.com/search?cflt=restaurants&find_loc=San+Francisco%2C+CA"
yelp_r = requests.get(url)
yelp_soup = bs(yelp_r.text, "html.parser")
ul = yelp_soup.find('ul', {'class':'lemon--ul__373c0__1_cxs undefined list__373c0__2G8oH'})
for li in ul.find_all('li', {'class':'lemon--li__373c0__1r9wz border-color--default__373c0__3-ifU'}):
for a_tag in li.find_all("a", {'class':"lemon--a__373c0__IEZFH link__373c0__1G70M link-color--inherit__373c0__3dzpk link-size--inherit__373c0__1VFlE"}):
print(a_tag.text) # get the text
print(a_tag.get('name')) # get the name property of a tag
output
Boo Koo
Boo Koo
Fog Harbor Fish House
Fog Harbor Fish House
... some results remove
Gary Danko
Gary Danko
um.ma
um.ma
Примечание. Я не исследовал, является ли имя класса Dynami c и изменяется ли