python - How to parse Selenium driver elements? -
i'm new in selenium python. i'm trying scrape data can't figure out how parse outputs commands this:
driver.find_elements_by_css_selector("div.flightbox")
i trying google tutorial i've found nothing python.
could give me hint?
find_elements_by_css_selector()
return list of webelement
instances. each web element has number of methods , attributes available. example, inner text of element, use .text
:
for element in driver.find_elements_by_css_selector("div.flightbox"): print(element.text)
you can make context-specific search find other elements inside current element. taking account, i know site working with, here example code departure , arrival times first-way flight in 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 study getting started, navigating , locating elements documentation pages.
Comments
Post a Comment