nginx/apache web服务器的搜索引擎分析器

botstat的Python项目详细描述


botstat

Build StatusLatest VersionPython VersionsTests CoverageDownloads

botstat是一个小型实用程序,通过搜索引擎bots来监视网站的爬网速度。 一旦你运行它,它会以csv格式向你的电子邮件发送机器人爬网率统计数据。

此外,它还有助于发现可能出现问题的根源。爬网速率取决于许多参数。我们试图给出不同搜索引擎的站点生产力的图片:google、bing、yahoo、baidu、yandex、sogou等。

例如,根据谷歌的网站管理员博客,如果你的网站在一段时间内快速响应,爬网限制就会上升,这意味着可以使用更多的连接进行爬网。如果站点速度变慢或响应服务器错误,则限制将降低,googlebot爬行的次数将减少。其他搜索引擎在大多数情况下都有类似的逻辑。

安装

pip

pip install botstat

或来源

git clone git@github.com:EndurantDevs/botstat-seo.git
cd botstat-seo
python setup.py install

如果要确认安装成功,请检查botstat命令行实用程序。

通常,此工具与cron一起使用。同样,请添加您的配置并配置您的crontab

运行测试

要确保从源代码安装之前一切正常,请运行:

python setup.py test

pytest tests/

用法

如果您在~/.botstat或/etc/botstat.conf处有配置,您只需执行

botstat

或者如果您在自定义路径上有配置

botstat -c /path/to/your/config 

或者如果您想从命令行提供所有参数

botstat --access-log access.log --debug --log-format '$remote_addr $host $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_time -$http_x_forwarded_for-' --smtp-port 10025 --mail-to "you@gmail.com" --mail-from "root@localhost"

帮助

$ botstat --help
usage: botstat [-h] [-c MY_CONFIG] [--verbose] [--debug]
               [--log-format LOG_FORMAT] [--nginx-config NGINX_CONFIG]
               [--access-log ACCESS_LOG] [--day-start DAY_START]
               [--date-start DATE_START] [--mail-to MAIL_TO]
               [--mail-from MAIL_FROM] [--mail-subject MAIL_SUBJECT]
               [--smtp-host SMTP_HOST] [--date-format DATE_FORMAT]
               [--smtp-port SMTP_PORT] [--server-type {nginx,apache}]
               [--xlsx-report]

Parse web server logs and make bots statistic Args that start with '--' (eg.
--verbose) can also be set in a config file (/etc/botstat.conf or ~/.botstat
or specified via -c). Config file syntax allows: key=value, flag=true,
stuff=[a,b,c] (for details, see syntax at https://goo.gl/R74nmi). If an arg is
specified in more than one place, then commandline values override config file
values which override defaults.

optional arguments:
  -h, --help            show this help message and exit
  -c MY_CONFIG, --my-config MY_CONFIG
                        config file path
  --verbose             Verbose output
  --debug               Enable debug mode
  --log-format LOG_FORMAT
                        Web server log format like 'log_format' in nginx.conf.
                        Accept 'combined', 'common' or format string field
                        names with $
  --nginx-config NGINX_CONFIG
                        Nginx config file name with path
  --access-log ACCESS_LOG
                        Access log file name. If not specify used stdin.
  --day-start DAY_START
                        Days from the beginning of today, all older records
                        skipped
  --date-start DATE_START
                        Start date for parsing log, all older records skipped
  --mail-to MAIL_TO     Email address to send report
  --mail-from MAIL_FROM
                        'Email FROM' address
  --mail-subject MAIL_SUBJECT
                        Report email subject
  --smtp-host SMTP_HOST
                        SMTP server host name or ip adddress
  --date-format DATE_FORMAT
                        A format string for a date/time field in 'time_local'
                        log field.To see the full set of format codes
                        supported on your platform, consult the strftime(3)
                        documentation.
  --smtp-port SMTP_PORT
                        SMTP server port
  --server-type {nginx,apache}
                        Web server type, support nginx and apache (default:
                        nginx)
  --xlsx-report         Report in excel format (it's required for xlsxwriter
                        module - run "pip install xlsxwriter" to install)

使用

构建
  • ConfigArgParse-替换argparse的一个插件,它还允许通过配置文件和/或环境变量设置选项
  • pytest-framework使编写小型测试变得容易,但是可以扩展以支持应用程序和库的复杂功能测试
  • apache-log-parser-分析来自apache日志的日志行

作者

Endurant Developers Python Team

许可证

这个项目是根据麻省理工学院的许可证授权的-请参见LICENSE文件以了解详细信息

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

推荐PyPI第三方库


热门话题
Java:字符串。RTL设备语言用标志“+”格式化,数字后加符号   java GAE作为桌面应用程序(Swing)的服务提供商   java将InputStream转换为FileInputStream不适用于Apache POI   java外部Voronoi库“网格”:什么是草图和处理?   重载重写的泛型方法java   java显示组织上设置的错误。springframework。验证。jsp中的错误对象   java一些Spring模型属性没有显示在我的JSP中   java无法编译Guava 23的SimpleTimeLimiter示例   java如何更改JTree中的“根”目录名?   java如何在安卓中对相对布局产生连锁反应?   java错误:org。冬眠例外SQLGrammarException:无法提取结果集,dateAccessed是未知列   如何使用java监听JSON文件更新   由抽象封闭类创建的匿名内部类能否通过反射确定实现类?