-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc.py
More file actions
21 lines (19 loc) · 849 Bytes
/
c.py
File metadata and controls
21 lines (19 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
def getLocation():
chrome_options = Options()
chrome_options.add_argument("--use-fake-ui-for-media-stream")
timeout = 20
driver = webdriver.Chrome(chrome_options=chrome_options,executable_path="./Desktop/pi-object-detection/chromedriver")
driver.get("https://mycurrentlocation.net/")
wait = WebDriverWait(driver, timeout)
longitude = driver.find_elements_by_xpath('//*[@id="longitude"]')
longitude = [x.text for x in longitude]
longitude = str(longitude[0])
latitude = driver.find_elements_by_xpath('//*[@id="latitude"]')
latitude = [x.text for x in latitude]
latitude = str(latitude[0])
driver.quit()
return (latitude,longitude)
print(getLocation())