Skip to content

Instantly share code, notes, and snippets.

@dvreed77
Created January 25, 2016 03:31
Show Gist options
  • Save dvreed77/e7a3f3ece6e8f6760b4c to your computer and use it in GitHub Desktop.
Save dvreed77/e7a3f3ece6e8f6760b4c to your computer and use it in GitHub Desktop.
from selenium import webdriver
# driver = webdriver.Firefox()
driver = webdriver.PhantomJS()
driver.set_window_size(1120, 550)
driver.get("https://duckduckgo.com/")
driver.find_element_by_id('search_form_input_homepage').send_keys("google slavery")
driver.find_element_by_id("search_button_homepage").click()
out = driver.find_elements_by_xpath("//div[@id='links']/div")
# out
for o in out:
try:
a = o.find_element_by_css_selector('a')
print a.get_attribute('href')
except:
break
# print driver.current_url
# driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment