In my python project I want to get my gps location. So I've thought of parsing a website which gives me these information: https://www.where-am-i.net/ works perfect! So I wrote the following script for parsing out the Latitude, Longitude:
from bs4 import BeautifulSoup
import requests
#website = "https://schlechtewitze.com/kurze-witze"
website = "https://www.where-am-i.net/"
source = requests.get(website).text
soup = BeautifulSoup(source, 'lxml')
for div in soup.find_all('div', class_ = "location"):
summary = div.p.text
print(summary)
print()
And it almost works, but only almost: It returns: My location is: 0.0, 0.0
As you can see, it returns not the true location, because my computer (windows 10) blocks the location request. For example when I open it in my browser:
The location will only be shown after i clicked to allow (Zulassen in german) the website to get my computers location.
BUT in the script i can't "click this button".
Question Result: How can I allow the website to get my location via the script (beautiful soup, requests)?
(I would not mind if there is another solution (without bs4) to get my GPS location)
As MukundKulkarni mentioned there's this tutorial, which uses Selenium, to parse a website: How I Understood: Getting accurate current geolocation using Python Web-scraping and Selenium
Obviously they don't have to allow the location tracking first. I'll use Selenium for further web-scraping.