Created
January 25, 2016 03:31
-
-
Save dvreed77/e7a3f3ece6e8f6760b4c to your computer and use it in GitHub Desktop.
Selenium: more here: https://realpython.com/blog/python/headless-selenium-testing-with-python-and-phantomjs/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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