I am trying to figure out web scraping using Selenium, but keep bumping into issues with syntax. Can someone please help me understand how to modify my code so that it displays the day, weather, and temps for the first 8 days that pop up in google search? Thanks!
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
url = 'https://www.google.com/search?q=perth+weather'
driver.get(url)
days = driver.find_elements(By.CLASS_NAME, "wob_df wob_ds")
for day in days:
name = day.find_element(By.XPATH, './/*[@id="wob_dp"]/div[1]/div[1]').text
rain = day.find_element(By.XPATH, './html/body/div[7]/div/div[11]/div[1]/div[2]/div[2]/div/div/div[1]/div/div/div/div/div[3]/div[3]/div/div[1]/div[2]').text
temp_min = day.find_element(By.XPATH, './/*[@id="wob_dp"]/div[1]/div[3]/div[1]').text
temp_max = day.find_element(By.XPATH, './/*[@id="wob_dp"]/div[1]/div[3]/div[2]').text
print(name, rain, temp_min, temp_max)