I am learning python and trying to paste the search results from python.org. I'm using Selenium
.
Steps I want to do:
- open python.org
- Search for term "array" (Displays the results)
- paste the list of search items (print("searchResults"))
My Code:
from selenium import webdriver
import time
driver = webdriver.Chrome(executable_path="/usr/local/bin/chromedriver")
#waiting to find the element before throwing error no element found
driver.implicitly_wait(10)
#driver.maximize_window()
#getting the website
driver.get("https://www.python.org/")
driver.implicitly_wait(5)
#finding element by id
driver.find_element_by_id("id-search-field").send_keys("arrays")
driver.find_element_by_id("submit").click()
print("Test Successful")
SearchResults = driver.find_element_by_xpath("/html/body/div[1]/div[3]/div/section/form/ul")
print(SearchResults.text)
-> This pastes all results.
Now I want individual results items and their headers. When I inspect the searchresults on site, I get this: <a href="/dev/peps/pep-0209/">PEP 209 -- Multi-dimensional Arrays</a>
There is no Tag, no Class and no Name to use.
How do I use this to just get all the headers?