crawler-utils
Scrapy utils for Modis crawlers projects.
MongoDB
Some utils connected with mongodb.
MongoDBPipeline - pipeline for saving items in mongodb.
Params:
- MONGODB_SERVER - address of mongodb database.
- MONGODB_PORT - port of mongodb database.
- MONGODB_DB - database where to save data.
- MONGODB_USERNAME - username for authentication in MONGODB_DB database.
- MONGODB_PWD - password for authentication.
- DEFAULT_MONGODB_COLLECTION - default collection where to save data (default value is
test). - MONGODB_COLLECTION_KEY - key of item which identifies items collection name (
MONGO_COLLECTION) where to save item (default value iscollection). - MONGODB_UNIQUE_KEY - key of item which identifies item
Kafka
Some utils connected with kafka.
KafkaPipeline - pipeline for pushing items into kafka.
Pipeline outputs data into stream with name {RESOURCE_TAG}.{DATA_TYPE}.
Where RESOURCE_TAG is tag of resource from which data is crawled and DATA_TYPE is type of
data crawled: data, post, comment, like, user, friend, share, member, news,
community.
Params:
- KAFKA_ADDRESS - address of kafka broker.
- KAFKA_KEY - key of item which is put into kafka record key.
- KAFKA_RESOURCE_TAG_KEY - key of item which identifies item
RESOURCE_TAG(default value isplatform) - KAFKA_DEFAULT_RESOURCE_TAG - default
RESOURCE_TAGfor crawled items withoutKAFKA_RESOURCE_TAG_KEY(default value iscrawler) - KAFKA_DATA_TYPE_KEY - key of item from which identifies item
DATA_TYPE(default value istype). - KAFKA_DEFAULT_DATA_TYPE - default
DATA_TYPEfor crawled items withoutKAFKA_DATA_TYPE_KEY(default value isdata). - KAFKA_COMPRESSION_TYPE - type of data compression in kafka for example
gzip.
OpenSearch
OpenSearchRequestsDownloaderMiddleware transforms request-response pair into an item, and then sends it to the OpenSearch.
Settings:
`OPENSEARCH_REQUESTS_SETTINGS` - dict specifying OpenSearch client connections:
"hosts": Optional[str | list[str]] = "localhost:9200" - hosts with opensearch endpoint,
"timeout": Optional[int] = 60 - timeout of connections,
"http_auth": Optional[tuple[str, str]] = None - HTTP authentication if needed,
"port": Optional[int] = 443 - access port if not specified in hosts,
"use_ssl": Optional[bool] = True - usage of SSL,
"verify_certs": Optional[bool] = False - verifying certificates,
"ssl_show_warn": Optional[bool] = False - show SSL warnings,
"ca_certs": Optional[str] = None - CA certificate path,
"client_key": Optional[str] = None - client key path,
"client_cert": Optional[str] = None - client certificate path,
"buffer_length": Optional[int] = 500 - number of items in OpenSearchStorage's buffer.
`OPENSEARCH_REQUESTS_INDEX`: Optional[str] = "scrapy-job-requests" - index in OpenSearch.
See an example in examples/opensearch.
CaptchaDetection
Captcha detection middleware for scrapy crawlers. It gets the HTML code from the response (if present), sends it to the captcha detection web-server and logs the result.
If you don't want to check exact response if it has captcha, provide meta-key dont_check_captcha
with True value.
The middleware must be set up with higher precedence (lower number) than RetryMiddleware:
DOWNLOADER_MIDDLEWARES = {
"crawler_utils.CaptchaDetectionDownloaderMiddleware": 549, # By default, RetryMiddleware has 550
}
Middleware settings:
- ENABLE_CAPTCHA_DETECTOR: bool = True. Whether to enable captcha detection.
- CAPTCHA_SERVICE_URL: str. For an example: http://127.0.0.1:8000
Sentry logging
You may want to log exceptions during crawling to your Sentry.
Use the crawler_utils.sentry_logging.SentryLoggingExtension for this.
Note that sentry_sdk wants to be loaded as earlier as possible.
To satisfy this condition make the extension with negative order:
EXTENSIONS = {
# Load SentryLogging extension before other extensions.
"crawler_utils.sentry_logging.SentryLoggingExtension": -1,
}
Settings:
SENTRY_DSN: str - Sentry's DSN, where to send events.
SENTRY_SAMPLE_RATE: float = 1.0 - sample rate for error events. Must be in range from 0.0 to 1.0.
SENTRY_TRACES_SAMPLE_RATE: float = 1.0 - the percentage chance a given transaction will be sent to Sentry.
SENTRY_ATTACH_STACKTRACE: bool = False - whether to attach stacktrace for error events.
SENTRY_MAX_BREADCRUMBS: int = 10 - max breadcrumbs to capture with Sentry.
For an example, check examples/sentry_logging.
Metadata
Release files for modis-crawler-utils 0.3.58
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modis_crawler_utils-0.3.58.tar.gz | 74.8 kB | Without provenance | Details for modis_crawler_utils-0.3.58.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| modis_crawler_utils-0.3.58-py3-none-any.whl | Python 3 | none | any | Details for modis_crawler_utils-0.3.58-py3-none-any.whl |
Total release size: 183.4 kB
Release files / modis_crawler_utils-0.3.58.tar.gz
| Download URL | modis_crawler_utils-0.3.58.tar.gz |
|---|---|
| Size | 74.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d41b4b4a1c7accec11339e0f84c06e4014544d485ef5a0734e647de4ae2931c
|
|
BLAKE2b-256 checksum How to use checksums |
54568b4757f4e1cf532a8965e94e312998da257f1652138efec1e02803823925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Release files / modis_crawler_utils-0.3.58-py3-none-any.whl
| Download URL | modis_crawler_utils-0.3.58-py3-none-any.whl |
|---|---|
| Size | 108.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69909cf95e0c78be655c1117f1cf134490887cea582cca44c0175aa8a4d9ffdd
|
|
BLAKE2b-256 checksum How to use checksums |
c6e37b0f7d43e2819c5de02f8e28d1d3aa218adf0cd77de79d562e0e1494ee3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.23
|
Security for modis-crawler-utils 0.3.58
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.