Skip to main content

A Scrapy extension that report your log from your scraped data.

Project description

Scrapy Log Report Extension

A Scrapy extension that report your log from your scraped data.

Usage

This Scrapy extension provides a way to report your log from your scraped data. It will generate a report every LOGSTATS_INTERVAL seconds, and send it to your log server.

# log report demo
{
  "items_add": 0,
  "pages_add": 0,
  "items_rate": 0,
  "pages_rate": 0,
  "items_count": 0,
  "pages_count": 0,
  "spider_name": "douban",
  "log_count/INFO": 8,
  "log_count/DEBUG": 1,
  "log_count/WARNING": 2,
  "item_scraped_add_count": 0,
  "response_received_add_count": 0
}

Installation

First, pip install this package:

$ pip install masterai-scrapy-extensions

Usage

Enable the extension in your project's settings.py file, by adding the following lines:

EXTENSIONS = {
    "masterai_scrapy_extensions.logreport.ReportStats": 100,
}
#
LOGSTATS_INTERVAL = 60
# set the URL to your log server
# method POST is used to send the report data
LOGREPORT_URL = "http://127.0.0.1:5000/api/v1/task/worker/status"

# log color
from masterai_scrapy_extensions import logcolor

logcolor.log_color_init()

That's all! Now run your job and have a look at the field stats.

Settings

The settings below can be defined as any other Scrapy settings, as described on Scrapy docs.

  • LOGREPORT_URL: set the interval in seconds to generate the report.
  • LOGSTATS_INTERVAL: set the URL to your log server,method POST is used to send the report data.
  • COLORLOG_FORMAT: log color format.
  • COLORLOG_COLORS: log colors.
  • COLORLOG_DATEFORMAT: log color date format.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

masterai_scrapy_extensions-2024.7.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

masterai_scrapy_extensions-2024.7.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file masterai_scrapy_extensions-2024.7.2.tar.gz.

File metadata

File hashes

Hashes for masterai_scrapy_extensions-2024.7.2.tar.gz
Algorithm Hash digest
SHA256 554428355a55a825754340ba44fefbfe36c1c3ea92bf7e4b6c5087421ecbaa1a
MD5 3dddaca1a3dd7940d15a6d34b5b6906c
BLAKE2b-256 ea8d83766653685d27b9ea3af1e068993dd7e959237c6ff70b23dd53d29c7298

See more details on using hashes here.

File details

Details for the file masterai_scrapy_extensions-2024.7.2-py3-none-any.whl.

File metadata

File hashes

Hashes for masterai_scrapy_extensions-2024.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 53dbb1cd8284c21b6d7a39964caf1c87bf27ac72b0b3a136ee2bae5b1389bbc8
MD5 ed2aa3a0a5a14ebcbf1deb3bf19a5252
BLAKE2b-256 a831433fcd0473ebdd86e89f837f04fe6637f7a95c9548b53c6d62166204fb88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page