-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrivingdirections.py
More file actions
75 lines (47 loc) · 2.02 KB
/
drivingdirections.py
File metadata and controls
75 lines (47 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# import required modules
from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
PATH="C:\Program Files (x86)\chromedriver.exe"
options = webdriver.ChromeOptions()
options.headless = True
options.add_argument('user-agent=fake-useragent')
driver = webdriver.Chrome(PATH, options=options)
Destination=input("What is the start point?")
StartPoint=input("What is the destination?")
Mode=input("What is the mode of transportation?")
# assign url in the webdriver object
driver.get("https://www.google.co.in/maps/@29.7228454,-98.6930793,15z")
sleep(2)
# search locations
def searchplace():
Place = driver.find_element(By.CLASS_NAME,"tactile-searchbox-input")
Place.send_keys(StartPoint)
Submit = driver.find_element(By.ID,
"searchbox-searchbutton")
Submit.click()
searchplace()
# get directions
def directions():
sleep(5)
directions = driver.find_element(By.CLASS_NAME,
"S9kvJb")
directions.click()
directions()
def route():
sleep(10)
route = driver.find_element(By.XPATH, "/html/body/div[3]/div[9]/div[3]/div[1]/div[2]/div/div[3]/div[1]/div[1]/div[2]/div[1]/div/input")
route.send_keys(Destination)
route.send_keys(u'\ue007')
sleep(10)
pasgod = driver.find_element(By.XPATH,"/html/body/div[3]/div[9]/div[9]/div/div/div[1]/div[2]/div/div[1]/div/div/div[4]/div[1]")
pasgod.click()
sleep(10)
kawhi = driver.find_element(By.CLASS_NAME, "delay-light")
sleep(5)
hello=driver.find_element(By.CLASS_NAME, "M3pmwc")
print("The eta is"+ " " + "in" + " " + kawhi.text+ ".")
y=hello.text
z=y.replace("These directions are for planning purposes only. You may find that construction projects, traffic, weather, or other events may cause conditions to differ from the map results, and you should plan your route accordingly. You must obey all signs or notices regarding your route.","")
print(z)
route()