Я пытаюсь очистить данные о широте и долготе с помощью кнопки «Показать карту» на этой странице результатов: https://www.psychologytoday.com/us/therapists/60148/374863?sid=5d01e84909804&ref=2&tr=ResultsName
Вот что я пробовал до сих пор =
button = soup.find('button', {"data-event-label":'Address_MapButton'})
print(button['data-map-lat'])
Полный код:
запросы на импорт
из bs4 импортировать BeautifulSoup
из bs4.element import Tag
zipcode = int(input("Zipcode: "))
url = 'https://www.psychologytoday.com/us/therapists/{0}'.format(zipcode)
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
page = requests.get(url, headers=headers)
soup = BeautifulSoup(page.text, 'html.parser')
result = soup.find(class_='results-column')
addressArray = []
for tag in result:
if isinstance(tag,Tag):
_class = tag.get("class")
if _class is None or _class is not None and "row" not in _class:
continue
link = (tag.find(class_='result-actions')).find('a',href=True)
_href = link['href']
address_link = requests.get(_href, headers=headers)
soup1 = BeautifulSoup(address_link.text, 'html.parser')
address = (soup1.find(class_='address')).find(class_="location-address-phone")
button = soup.find('button', {"data-event-label":'Address_MapButton'})
print(button['data-map-lat'])
print(addressArray)
Я получаю возвращение None.
Я хотел бы видеть координаты широты.