Reputation: 167
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"])
Upvotes: 0
Views: 110
Reputation: 166
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 .
Upvotes: 5