Oct-18-2020, 03:23 PM
(Oct-18-2020, 01:04 PM)snippsat Wrote:find_element_by_css_selector()
return a list.
Don't need a.click()
on search_bar.
Also add delay before trying to get content in linktime.sleep
a fast first way when testing,or look at Waits
browser.get('https://duckduckgo.com') search_bar = browser.find_elements_by_css_selector('#search_form_input_homepage')[0] #search_bar.click() search_bar.send_keys('liveleak') search_bar.submit() time.sleep(3) first_link = browser.find_elements_by_css_selector('#r1-0 > div:nth-child(1) > h2:nth-child(1) > a:nth-child(1)') print(first_link[0].text)
Output:LiveLeak.com - Redefining the Media
thank you , i was getting frustrated with this i kept going over and over the html link , i thought i was about to have to start taking html and css classes : ) just to figure this out.