1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| from selenium import webdriver
def use_phantom(): service_args = ['--proxy=proxy3.fn.com:8080', '--proxy-type=http'] driver = webdriver.PhantomJS(executable_path="/Users/demo/SOFT/phantomjs/phantomjs-2.1.1-macosx/bin/phantomjs", service_args=service_args) driver.get("https://www.google.com") driver.get_screenshot_as_file("phantomjsGoogle.png") driver.close()
def use_chrome(): chrome_options = webdriver.ChromeOptions() chrome_options.add_argument("--proxy-server=proxy3.fn.com:8080") chrome_options.add_argument("--proxy-type=http") driver = webdriver.Chrome(executable_path="/Users/xuzhuo/SOFT/chromedriver/chromedriver", chrome_options=chrome_options) driver.get("https://www.google.com") driver.get_screenshot_as_file("chromeGoogle.png") driver.close()
use_phantom() use_chrome()
|