When I visit this site and write any address, as in Taekwondo Mattighofen, Am Steinbach, Lochen am See, Austria
in inputbox under ENTER A LOCATION
, I can see this autocompletion url in dev tools which has parameters like this. The full form of that autocompleted url looks like this, which produces the value of latitude and longitude.
I've found success using the value of latitude and longitude taken manually from that above mentioned api within my following script to produce the end result, though.
import requests
from bs4 import BeautifulSoup
link = 'https://www.ktm.com/content/websites/ktm-com/middle-east/ae/en/dealer-search/jcr:content/root/responsivegrid_1_col/dealersearch.dealers.json'
params = {
'latitude': '48.0075483',
'longitude': '13.1848824',
'country': '',
'qualification': '',
'distance': '50'
}
with requests.Session() as s:
s.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36'
res = s.get(link,params=params)
print(res.json())
How can I produce such autocompletion url based on any address like
Nachhilfe Mattighofen, Rosengasse, Mattighofen, Austria
using a python script built upon requests?
from Trouble forming an autocompletion url using requests
No comments:
Post a Comment