0

I am using BeautifulSoup.

I would like to extract a coordinates from the website. The code of web looks like:

<a class="button button--outline link link--emphasis button-full-width js-choose-store" href="/sklep?StoreID=R034" title="Informacje o sklepie">Informacje o sklepie</a>
</div>
</div>
</div>
</div>
<div class="storelist__item ui-expandable js-accordion-store js-store" data-lat="52.225155" data-lng="20.998965" data-icon="/on/demandware.static/Sites-Hebe-Site/-/default/dw081970e9/images/map_markers/hebe.png" data-id="R379" data-coming-soon="false" data-index="81">
<div class="visually-hidden" data-popup-html>
<div class="store-popup">
<div class="store-popup__name text--uppercase">Drogeria Hebe</div>
<div class="store-popup__address">Lindleya 16</div>
<div class="store-popup__city">Warszawa, 02-013</div>
<div class="store-popup__directions">

I need to get 'data-lat' and 'data-lng'.

I had no problem to get address or name of object (it was a text), using for example:

find("div",{"class","store-popup__city"}).text

Coya
  • 13
  • 3

1 Answers1

0

Try something along the lines of:

dat = soup.select_one('div[data-lat]')
print(dat['data-lat'],dat['data-lng'])

Output:

52.225155 20.998965

Jack Fleeting
  • 24,385
  • 6
  • 23
  • 45