Web scraper using dynamic proxy and user agent.
Description
Scraperex is simple and easy to use web scraper for retreiving data from request and avoiding HTTP 503 error (usually emerges when server is watching for bots/crawlers/requests while regular scraping).
Pakage is generating random user-agent headers using fake-useragent, and a list of proxy servers that is used while maiking requests.
Installation
pip install scraperex
Dependencies
Usage
import scraperex
Scrape textual response
Basic usage requires one paramether of type dictionary which contains url to the web resource, and regex which will extract the data from the response.
config = {
'my_scraping': {
'method': 'GET',
'url': 'https://www.resource.for/scraping/1',
'params': { perPage: 5 },
'regex': r'my_regular_expression'
}
}
result = scraperex.find(config)
Scrape json response
If you set configuration json option True then regex option will be ignored and (requests) response.json() will be invoked.
config = {
'my_scraping': {
'method': 'GET',
'url': 'https://www.resource.for/scraping/2',
'params': { perPage: 5 },
'json': True
}
}
result = scraperex.find(config)
Note: If proxy server fails, next one from the list will be used, while proxy list is not exhausted or limit is not touched. You can set limitation by sending attempts parameter. By default attempts are set to 3.
result = scraperex.find(config, attempts = 1)
Config
Config config must be of type dictionary which must contain at least one item used for scraping (as you can guess the amount of the requests will equal at least to the items amount).
Note: You also can build a tree of configurations and the same structure will be in your result.
config = {
'item_A': {...},
'item_B': {
'item_C': {..},
'item_D': {..},
}
}
Structured textual ( regex ) results
You can rescrape response content as many times as you wish by passing to regex property dictionary instead of string (also it is useful if you want to structure your results, scraping will result in the same structure you defined).
'item_B': {
'url': 'https://www.resource.for/scraping/2',
'regex': {
'structure_item': {
'child_structure_item_1': r'my_regular_expression'
}
'structure_item_1': r'my_regular_expression_1'
}
}
Note: Constructive criticism is always awaited, please share your thoughts with me: GitHub.
Metadata
Release files for scraperex 0.2.1
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 |
|---|---|---|---|---|
| scraperex-0.2.1.tar.gz | 5.2 kB | Without provenance | Details for scraperex-0.2.1.tar.gz |
Release files / scraperex-0.2.1.tar.gz
| Download URL | scraperex-0.2.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
291e11013eb60548c586f7d6d3a962882a44edf706da4fa1f610ba0b4cd91915
|
|
BLAKE2b-256 checksum How to use checksums |
f571aa9dec3d844cb9a8dbbcc5f641fedad967a8b5465071bd5252a08e7e2568
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for scraperex 0.2.1
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.