0

Is there an easier way to find the coordinates from the html of this url = https://www.sreality.cz/detail/prodej/byt/1+kk/praha-zizkov-krasova/151897164

I inspected the site but so far it doesnt look like there is any coordinates. the site is using mapy.cz

I tried to convert the adress to coordinates but the coordinates are sometimes off.

This is what i tried:

address = 'praha zizkov krasova'
url = 'https://nominatim.openstreetmap.org/search/' + urllib.parse.quote(address) +'?format=json'

response = requests.get(url).json()
print(response[0]["lat"])
print(response[0]["lon"])
Reda S
  • 167
  • 12
  • Dont't think tho cordinates are included in the html, but maybe https://stackoverflow.com/a/32333188/20443541 helps you. – kaliiiiiiiii Feb 07 '23 at 13:17

1 Answers1

5

you can find the latitude and longitude values using the site's API:

https://www.sreality.cz/api/en/v2/estates/{property_id}

You can find the property_id on the property page's url (The long number at the end of the url). For the link you sent it's 151897164. This is an example for another property from the same site:

import requests as r
property_id = 4257355596
postURL = f"https://www.sreality.cz/api/en/v2/estates/{property_id}"
results_post = r.get(postURL).json()
print("lat: ", results_post["map"]["lat"])
print("lon: ", results_post["map"]["lon"])

I can also suggest using Scrapy as an alternative framework to crawl these stuff and also running this crawler on a spider management solution like estela .