Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
DiscordBot/WebSite.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
23 lines (17 sloc)
920 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import selenium | |
from selenium import webdriver | |
import time | |
'''Function: Runs a chrome browser, inserts the postcode into the search bar, searches and then returns the URL. | |
Innput: String (Postcode), Output: String (msg)''' | |
def Maps(Postcode): | |
# Using Chrome to access web | |
driver = webdriver.Chrome(executable_path=r'C:\Users\Kieran\Desktop\A.L.L Project\ChatBot\DiscordBot-master\Selenium Maps/chromedriver.exe') | |
# Open the website | |
driver.get("https://www.google.com/maps") | |
Search_box = driver.find_element_by_id('searchboxinput') # The search box in Google Maps. | |
Search_box.send_keys(Postcode) # Inserts "Postcode" into the seach box | |
Search_button = driver.find_element_by_id('searchbox-searchbutton') # The search button in Google Maps | |
Search_button.click() | |
time.sleep(3) # Waits 3 seconds otherwise it returns None. | |
msg = driver.current_url # Sets the Url to "msg" | |
return msg | |