# -*- coding: utf-8 -*-from selenium import webdriverfrom time import sleepfrom selenium.webdriver.common.keys import Keysimport osdef useselenium(url): if 'HTTP_PROXY'in os.environ: del os.environ['HTTP_PROXY'] options=webdriver.ChromeOptions() options.add_argument('--headless') dr = webdriver.Chrome(chrome_options=options) dr.set_page_load_timeout(10) dr.set_script_timeout(10) try: dr.get(url) ## 到达下一个页面 print "title of current page is %s" %(dr.title) ## 打印Title. print "url of current page is %s" %(dr.current_url) ## 打印url. dr.get_screenshot_as_file("./myscreen/" + base64.b64encode(filename) +".png") except: print "Error " + url dr.quit()scan = open("domains.txt","r")scan_data = [line.strip() for line in scan.readlines()]scan.close()for line in scan_data: try: newline = line.split(",")[0] useselenium(newline) except: pass
https://1688.comhttps://baidu.com