I'm new in Selenium with Python. I'm trying to scrape some data but I can't figure out how to parse outputs from commands like this:
I was trying to google some tutorial but I've found nothing for Python.
Could you give me a hint?
Best How To :
find_elements_by_css_selector() would return you a list of
WebElement instances. Each web element has a number of methods and attributes available. For example, to get a inner text of the element, use
for element in driver.find_elements_by_css_selector("div.flightbox"):
You can also make a context-specific search to find other elements inside the current element. Taking into account, that I know what site are you working with, here is an example code to get the departure and arrival times for the first-way flight in a result box:
for result in driver.find_elements_by_css_selector("div.flightbox"):
departure_time = result.find_element_by_css_selector("div.departure p.p05 strong").text
arrival_time = result.find_element_by_css_selector("div.arrival p.p05 strong").text
print [departure_time, arrival_time]
Make sure you study Getting Started, Navigating and Locating Elements documentation pages.