I'm trying to automate accessing a Wikipedia page (without api) and parse the text, I can input the research value but struggle to select the first result from the input dropdown results (please open wikipedia if you don't know what I'm talking about). I tried extracting the XPATH from the webpage but still failed to make it work.
What I've tried
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://en.wikipedia.org/wiki/Main_Page")
elem = driver.find_element(By.NAME, "search")
elem.send_keys('Python')
elem = driver.find_element(By.XPATH, '/html/body/div[5]/div/a[2]/div')
elem.send_keys(Keys.RETURN)
Thanks