Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here's an example code to extract the thumbnail/photo URL and other data from Google Map using Selenium Scraper in Python:

from selenium import webdriver

# Set up the webdriver and open Google Maps
driver = webdriver.Chrome()
driver.get('https://www.google.com/maps')

# Search for the place you're interested in
search_box = driver.find_element_by_id('searchboxinput')
search_box.send_keys('San Francisco')
search_box.submit()

# Wait for the maps to load and switch to the first result
driver.implicitly_wait(10)
first_result = driver.find_element_by_css_selector('div.section-result:nth-child(1)')
first_result.click()

# Wait for the place details to load and get the thumbnail/photo URL and other data
driver.implicitly_wait(10)
thumbnail_url = driver.find_element_by_css_selector('img.section-hero-header-image-hero').get_attribute('src')
name = driver.find_element_by_css_selector('h1.section-hero-header-title-title').text
address = driver.find_element_by_css_selector('div[data-item-id="address"]').text
rating = driver.find_element_by_css_selector('span.section-star-display').text

# Print the results
print('Name:', name)
print('Address:', address)
print('Rating:', rating)
print('Thumbnail URL:', thumbnail_url)

# Close the webdriver
driver.quit()

This script opens Google Maps, searches for "San Francisco", clicks on the first result, waits for the place details to load, and then extracts the thumbnail/photo URL, name, address, and rating. You can modify this script to search for other places and extract different information as needed.