• python代码
    1. # -*- coding: utf-8 -*-
    2. from selenium import webdriver
    3. from time import sleep
    4. from selenium.webdriver.common.keys import Keys
    5. import os
    6. def useselenium(url):
    7. if 'HTTP_PROXY'in os.environ: del os.environ['HTTP_PROXY']
    8. options=webdriver.ChromeOptions()
    9. options.add_argument('--headless')
    10. dr = webdriver.Chrome(chrome_options=options)
    11. dr.set_page_load_timeout(10)
    12. dr.set_script_timeout(10)
    13. try:
    14. dr.get(url) ## 到达下一个页面
    15. print "title of current page is %s" %(dr.title) ## 打印Title.
    16. print "url of current page is %s" %(dr.current_url) ## 打印url.
    17. dr.get_screenshot_as_file("./myscreen/" + base64.b64encode(filename) +".png")
    18. except:
    19. print "Error " + url
    20. dr.quit()
    21. scan = open("domains.txt","r")
    22. scan_data = [line.strip() for line in scan.readlines()]
    23. scan.close()
    24. for line in scan_data:
    25. try:
    26. newline = line.split(",")[0]
    27. useselenium(newline)
    28. except:
    29. pass
    • domains.txt的内容
    1. https://1688.com
    2. https://baidu.com
    • 之后就可以在myscreen目录下看到截图。