LogParser v0.8.0 发布:一个用于定期增量式解析 Scrapy 爬虫日志的 Python 库,配合 ScrapydWeb 使用可实现爬虫进度可视化 - V2EX
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
my8100

LogParser v0.8.0 发布:一个用于定期增量式解析 Scrapy 爬虫日志的 Python 库,配合 ScrapydWeb 使用可实现爬虫进度可视化

  •  
  •   my8100
    my8100 Jan 21, 2019 2342 views
    This topic created in 2671 days ago, the information mentioned may be changed or developed.

    GitHub 开源

    https://github.com/my8100/logparser

    安装

    • 通过 pip:
    pip install logparser 
    • 通过 git:
    git clone https://github.com/my8100/logparser.git cd logparser python setup.py install 

    使用方法

    作为 service 运行

    1. 请先确保当前主机已经安装和启动 Scrapyd
    2. 通过命令 logparser 启动 LogParser
    3. 访问 http://127.0.0.1:6800/logs/stats.json (假设 Scrapyd 运行于端口 6800)
    4. 访问 http://127.0.0.1:6800/logs/projectname/spidername/jobid.json 以获取某个爬虫任务的日志分析详情

    配合 ScrapydWeb 实现爬虫进度可视化

    详见 https://github.com/my8100/scrapydweb visualization

    在 Python 代码中使用

    In [1]: from logparser import parse In [2]: log = """2018-10-23 18:28:34 [scrapy.utils.log] INFO: Scrapy 1.5.0 started (bot: demo) ...: 2018-10-23 18:29:41 [scrapy.statscollectors] INFO: Dumping Scrapy stats: ...: {'downloader/exception_count': 3, ...: 'downloader/exception_type_count/twisted.internet.error.TCPTimedOutError': 3, ...: 'downloader/request_bytes': 1336, ...: 'downloader/request_count': 7, ...: 'downloader/request_method_count/GET': 7, ...: 'downloader/response_bytes': 1669, ...: 'downloader/response_count': 4, ...: 'downloader/response_status_count/200': 2, ...: 'downloader/response_status_count/302': 1, ...: 'downloader/response_status_count/404': 1, ...: 'dupefilter/filtered': 1, ...: 'finish_reason': 'finished', ...: 'finish_time': datetime.datetime(2018, 10, 23, 10, 29, 41, 174719), ...: 'httperror/response_ignored_count': 1, ...: 'httperror/response_ignored_status_count/404': 1, ...: 'item_scraped_count': 2, ...: 'log_count/CRITICAL': 5, ...: 'log_count/DEBUG': 14, ...: 'log_count/ERROR': 5, ...: 'log_count/INFO': 75, ...: 'log_count/WARNING': 3, ...: 'offsite/domains': 1, ...: 'offsite/filtered': 1, ...: 'request_depth_max': 1, ...: 'response_received_count': 3, ...: 'retry/count': 2, ...: 'retry/max_reached': 1, ...: 'retry/reason_count/twisted.internet.error.TCPTimedOutError': 2, ...: 'scheduler/dequeued': 7, ...: 'scheduler/dequeued/memory': 7, ...: 'scheduler/enqueued': 7, ...: 'scheduler/enqueued/memory': 7, ...: 'start_time': datetime.datetime(2018, 10, 23, 10, 28, 35, 70938)} ...: 2018-10-23 18:29:42 [scrapy.core.engine] INFO: Spider closed (finished)""" In [3]: d = parse(log, headlines=1, taillines=1) In [4]: d Out[4]: OrderedDict([('head', '2018-10-23 18:28:34 [scrapy.utils.log] INFO: Scrapy 1.5.0 started (bot: demo)'), ('tail', '2018-10-23 18:29:42 [scrapy.core.engine] INFO: Spider closed (finished)'), ('first_log_time', '2018-10-23 18:28:34'), ('latest_log_time', '2018-10-23 18:29:42'), ('elapsed', '0:01:08'), ('first_log_timestamp', 1540290514), ('latest_log_timestamp', 1540290582), ('datas', []), ('pages', 3), ('items', 2), ('latest_matches', {'resuming_crawl': '', 'latest_offsite': '', 'latest_duplicate': '', 'latest_crawl': '', 'latest_scrape': '', 'latest_item': '', 'latest_stat': ''}), ('latest_crawl_timestamp', 0), ('latest_scrape_timestamp', 0), ('log_categories', {'critical_logs': {'count': 5, 'details': []}, 'error_logs': {'count': 5, 'details': []}, 'warning_logs': {'count': 3, 'details': []}, 'redirect_logs': {'count': 1, 'details': []}, 'retry_logs': {'count': 2, 'details': []}, 'ignore_logs': {'count': 1, 'details': []}}), ('shutdown_reason', 'N/A'), ('finish_reason', 'finished'), ('last_update_timestamp', 1547559048), ('last_update_time', '2019-01-15 21:30:48')]) In [5]: d['elapsed'] Out[5]: '0:01:08' In [6]: d['pages'] Out[6]: 3 In [7]: d['items'] Out[7]: 2 In [8]: d['finish_reason'] Out[8]: 'finished' 
    2 replies    2019-01-24 09:48:52 +08:00
    4BVL25L90W260T9U
        1
    4BVL25L90W260T9U  
       Jan 21, 2019
    为啥不用 grafana ?
    15399905591
        2
    15399905591  
       Jan 24, 2019
    膜拜下大佬,以前一直用 spiderkeeper,可那东西坑实在太多了。。
    About     Help     Advertise     Blog     API     FAQ     Solana     1180 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 37ms UTC 18:04 PVG 02:04 LAX 11:04 JFK 14:04
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86