截图网站列表的简单脚本

webscreenshot的Python项目详细描述


Webscreenshot

说明

一个简单的脚本,根据^{}phantomjs脚本截图网站列表。

功能

  • 为ajax资源集成url到图像'lazy-rendering'
  • 在Windows和Linux系统上完全正常工作
  • cookie和自定义http头定义支持
  • 用户可定义超时后的多处理和无响应进程的终止
  • 接受多种格式作为输入目标
  • 自定义屏幕截图大小(宽度、高度)
  • 映射phantomjs的有用选项,例如忽略ssl错误、代理定义和代理身份验证、http基本身份验证
  • 支持多个渲染器:
    • phantomjs,这是一个遗留的和abandoned但仍然产生最好的结果
    • chrome和chromium,它将替换phantomjs,但有一些限制:截图没有有效证书的https网站(例如自签名证书)将生成空截图。 原因是^{}选项不起作用,以后也不会起作用:解决方案是使用proper webdriver,但到目前为止webscreenshot并不是为了支持这个方法,这个方法相当复杂,需要一些第三方工具。
    • firefox也可以用作渲染器,但有一些严重的限制(因此暂时不要使用它):
      • 无法同时执行多个屏幕截图:Firefox进程没有多个实例
      • 没有匿名模式,使用webscreenshot将污染您的浏览历史

用法

将目标放在文本文件中,并使用-i选项传递,如果只有一个url,则将其作为位置参数传递。
屏幕截图将在您当前的./screenshots/目录(默认)中提供。
接受的输入格式如下:

http(s)://domain_or_ip:port(/ressource)
domain_or_ip:port(/ressource)
domain_or_ip(/ressource)

选项

webscreenshot.py version 2.3

usage: webscreenshot.py [-h] [-i INPUT_FILE] [-o OUTPUT_DIRECTORY]
                        [-w WORKERS] [-v]
                        [-r {phantomjs,chrome,chromium,firefox}]
                        [--renderer-binary RENDERER_BINARY] [--no-xserver]
                        [--window-size WINDOW_SIZE] [-p PORT] [-s] [-m]
                        [-c COOKIE] [-a HEADER] [-u HTTP_USERNAME]
                        [-b HTTP_PASSWORD] [-P PROXY] [-A PROXY_AUTH]
                        [-T PROXY_TYPE] [-t TIMEOUT]
                        [URL]

optional arguments:
  -h, --help            show this help message and exit

Main parameters:
  URL                   Single URL target given as a positional argument
  -i INPUT_FILE, --input-file INPUT_FILE
                        <INPUT_FILE> text file containing the target list. Ex:
                        list.txt
  -o OUTPUT_DIRECTORY, --output-directory OUTPUT_DIRECTORY
                        <OUTPUT_DIRECTORY> (optional): screenshots output
                        directory (default './screenshots/')
  -w WORKERS, --workers WORKERS
                        <WORKERS> (optional): number of parallel execution
                        workers (default 4)
  -v, --verbosity       <VERBOSITY> (optional): verbosity level, repeat it to
                        increase the level { -v INFO, -vv DEBUG } (default
                        verbosity ERROR)

Screenshot parameters:
  -r {phantomjs,chrome,chromium,firefox}, --renderer {phantomjs,chrome,chromium,firefox}
                        <RENDERER> (optional): renderer to use among
                        'phantomjs' (legacy but best results), 'chrome',
                        'chromium', 'firefox' (version > 57) (default
                        'phantomjs')
  --renderer-binary RENDERER_BINARY
                        <RENDERER_BINARY> (optional): path to the renderer
                        executable if it cannot be found in $PATH
  --no-xserver          <NO_X_SERVER> (optional): if you are running without
                        an X server, will use xvfb-run to execute the renderer
  --window-size WINDOW_SIZE
                        <WINDOW_SIZE> (optional): width and height of the
                        screen capture (default '1200,800')

Input processing parameters:
  -p PORT, --port PORT  <PORT> (optional): use the specified port for each
                        target in the input list. Ex: -p 80
  -s, --ssl             <SSL> (optional): enforce ssl for every connection
  -m, --multiprotocol   <MULTIPROTOCOL> (optional): perform screenshots over
                        HTTP and HTTPS for each target

HTTP parameters:
  -c COOKIE, --cookie COOKIE
                        <COOKIE_STRING> (optional): cookie string to add. Ex:
                        -c "JSESSIONID=1234; YOLO=SWAG"
  -a HEADER, --header HEADER
                        <HEADER> (optional): custom or additional header.
                        Repeat this option for every header. Ex: -a "Host:
                        localhost" -a "Foo: bar"
  -u HTTP_USERNAME, --http-username HTTP_USERNAME
                        <HTTP_USERNAME> (optional): specify a username for
                        HTTP Basic Authentication.
  -b HTTP_PASSWORD, --http-password HTTP_PASSWORD
                        <HTTP_PASSWORD> (optional): specify a password for
                        HTTP Basic Authentication.

Connection parameters:
  -P PROXY, --proxy PROXY
                        <PROXY> (optional): specify a proxy. Ex: -P
                        http://proxy.company.com:8080
  -A PROXY_AUTH, --proxy-auth PROXY_AUTH
                        <PROXY_AUTH> (optional): provides authentication
                        information for the proxy. Ex: -A user:password
  -T PROXY_TYPE, --proxy-type PROXY_TYPE
                        <PROXY_TYPE> (optional): specifies the proxy type,
                        "http" (default), "none" (disable completely), or
                        "socks5". Ex: -T socks
  -t TIMEOUT, --timeout TIMEOUT
                        <TIMEOUT> (optional): renderer execution timeout in
                        seconds (default 30 sec)

示例

list.txt
--------
http://google.fr
https://216.58.213.131
216.58.213.131
https://duckduckgo.com/robots.txt


Default execution with a list
-----------------------------
$ python webscreenshot.py version 2.3

[+] 4 URLs to be screenshot
[+] 4 actual URLs screenshot
[+] 0 error(s)


Default execution with a single URL
-----------------------------------
$ python webscreenshot.py -v google.fr
webscreenshot.py version 2.3

[INFO][General] 'google.fr' has been formatted as 'http://google.fr:80' with supplied overriding options
[+] 1 URLs to be screenshot
[INFO][http://google.fr:80] Screenshot OK

[+] 1 actual URLs screenshot
[+] 0 error(s)


Increasing verbosity level execution
-----------------------------------
$ python webscreenshot.py -i list.txt -v
webscreenshot.py version 2.3

[INFO][General] 'http://google.fr' has been formatted as 'http://google.fr:80' with supplied overriding options
[INFO][General] 'https://216.58.213.131' has been formatted as 'https://216.58.213.131:443' with supplied overriding options
[INFO][General] '216.58.213.131' has been formatted as 'http://216.58.213.131:80' with supplied overriding options
[INFO][General] 'https://duckduckgo.com/robots.txt' has been formatted as 'https://duckduckgo.com:443/robots.txt' with supplied overriding options
[+] 4 URLs to be screenshot
[INFO][https://duckduckgo.com:443/robots.txt] Screenshot OK

[INFO][http://216.58.213.131:80] Screenshot OK

[INFO][https://216.58.213.131:443] Screenshot OK

[INFO][http://google.fr:80] Screenshot OK

[+] 4 actual URLs screenshot
[+] 0 error(s)


Results
-------
$ ls -l screenshots/
total 187
-rwxrwxrwx 1 root root 53805 May 19 16:04 http_216.58.213.131_80.png
-rwxrwxrwx 1 root root 53805 May 19 16:05 http_google.fr_80.png
-rwxrwxrwx 1 root root 53805 May 19 16:04 https_216.58.213.131_443.png
-rwxrwxrwx 1 root root 27864 May 19 16:04 https_duckduckgo.com_443_robots.txt.png

要求

  • 版本为2.7或3.x的python解释器
  • webscreenshot python脚本:
    • 最简单的方法是设置它:pip install webscreenshot,然后直接使用$ webscreenshot
    • 或者git克隆存储库,然后pip install -r requirements.txt,然后python webscreenshot.py
  • 至少有版本2的phantomjs工具:遵循installation guide并检查FAQ如果需要
  • chrome、chrome或firefox>;57如果要使用这些渲染器之一
  • xvfb如果要在无头操作系统中运行webscreenshot:请使用--no-xserverwebscreenshot选项来简化所有操作

更改日志

  • 版本2.4-05/30/2019:Windows支持的少量修复程序
  • 版本2.3-05/19/2019:python 3兼容性,添加了firefox渲染器,未添加xserver选项
  • 版本2.2-08/13/2018:Chrome和Chrome渲染器支持和单个URL支持
  • 版本2.1-01/14/2018:添加多协议选项和PYPI包装
  • 版本2.0-03/08/2017:添加代理类型选项
  • 版本1.9-01/10/2017:使用所有SSL/TLS密码
  • 版本1.8-07/05/2015:选项组定义
  • 版本1.7-06/28/2015:http基本身份验证支持+日志级别选项更改为详细信息
  • 版本1.6-04/23/2015:透明背景修复
  • 版本1.5-01/11/2015:cookie和自定义http头支持
  • 版本1.4-10/12/2014:url到image phantomjs脚本集成+少数错误已纠正
  • 版本1.3-08/05/2014:Windows支持+少数错误已纠正
  • 版本1.2-04/27/2014:已更正的错误很少
  • 版本1.1-04/21/2014:将脚本更改为使用phantomjs而不是有错误的wkhtml二进制文件
  • 版本1.0-2014年12月1日:初始提交

版权和许可

webscreenshot是一个自由软件:您可以根据gnu通用pub的条款重新发布和/或修改它。由自由软件基金会发布的lic许可证,许可证的第3版,或(由您选择)任何更高版本。

分配是希望它是有用的,但没有任何保证;甚至没有适销性或适合某一特定目的的默示保证。

有关更多详细信息,请参阅GNU通用公共许可证。

您应该已经收到GNU通用公共许可证的副本以及Webscreenshot。 如果没有,请参阅http://www.gnu.org/licenses/

联系人

  • thomas debize<;tdebize,邮箱:d0t com>;

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何将java ArrayList对象转换为实际值   web服务如何在JAVA类uisng JAXBElement中解组SOAP UI值   包含无值参数的java HttpClient表单URL   运行简单Camel Restlet演示项目的java问题?   带有自定义图标的java简单SWT警报消息?   java Netbeans 6.8:LibImport可以工作,但编译时“包不存在”   java如何获得绘画完成的通知?   java Hazelcast客户端模式群集故障后如何恢复?   Neo4J中Shapefile的java批插入   为什么ThreadPoolExecutor在Eclipse和从命令行运行Java程序时表现不同?   java在Android中计算两个坐标之间的距离时得到了荒谬的值   java在CardLayout中显示卡本身的下一张卡