nginx/apache web服务器的搜索引擎分析器
botstat的Python项目详细描述
botstat
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日志的日志行
作者
许可证
这个项目是根据麻省理工学院的许可证授权的-请参见LICENSE文件以了解详细信息