<jupyter_start><jupyter_text>5. Write a program to scrap geospatial coordinates (latitude, longitude) of a city searched on google maps.<jupyter_code>#Connect to web driver
driver=webdriver.Chrome(r"D://chromedriver.exe")  #r converts string to raw string
#If not r, we can use executable_path = "C:/path name"
#Getting the website to driver
driver.get('https://www.google.com/maps')

#When we run this line, automatically the webpage will be opened
#Creating user input for entering the city manually
city=input("Enter City: ")

#Finding the required element and sending the keys
driver.find_element_by_xpath("//button[@class='searchbox-searchbutton']").send_keys(city)
#For Automatically entering the button, we will use Keys library and Keys.Enter function for automatically entering the input
driver.find_element_by_xpath("//button[@class='searchbox-searchbutton']").send_keys(Keys.ENTER)
#For finding the coordinates, we will use driver.current_url function that provides current url automatically
coordinates=driver.current_url
lat=coordinates.split('@')[1].split(',')[0]
long=coordinates.split('@')[1].split(',')[1].split(',')[0]
print('Latitude: ',lat)
print('Longitude: ',long)
#Closing the driver
driver.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1254996003197442, 'fraction_numerical': 0.004796163069544364, 'mean_word_length': 7.12987012987013, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '434776', 'license': 'MIT', 'n_tokens_mistral': 383, 'n_tokens_neox': 369, 'n_words': 116, 'path': 'Webscraping/Google/CityCoordinates_WebScraping.ipynb', 'repo_name': 'Jerish7/FlipRoboTechnologies-Internship', 'size': '1251'}