Skip to main content

Web scraper using dynamic proxy and user agent.

Project description

Scraperex

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

Basic usage requires definition a dictionary with one item that contains url to the web resource, and regex which will extract the data from the response.

from scraperex import Scraper

config = {
    'my_scraping': {
        'url': 'https://www.resource.for/scraping/1',
        'regex': r'my_regular_expression'
    }
}

scraper = Scraper()
result = scraper.get(config)

Config

Config config must be of type dictionary which contains items used for scraping (as you can guess the amount of the requests will equal at least to the items amount).

Note: In case when current proxy fails next proxy server from the list will be used which will make one another request.

config = {
    'item_A': {...},
    'item_B': {...}
}

Each config item must contain two predefined properties url and regex.

    'item_A': {
        'url': 'https://www.resource.for/scraping/1',
        'regex': r'my_regular_expression'
    }

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 acceptable, please share your thoughts with me: GitHub.

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

scraperex-0.0.5.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file scraperex-0.0.5.tar.gz.

File metadata

  • Download URL: scraperex-0.0.5.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for scraperex-0.0.5.tar.gz
Algorithm Hash digest
SHA256 11e30bf7c232a4c4c35a60c29e8d619f70ac64dad647bf8acc2d3fa4bdd4f191
MD5 ba1e131aff9cc2e39c1a6bd076c39556
BLAKE2b-256 cc3557cbdb8499f44e0c27dbf35f50f24b51da64a9eb90297bbc208c9f7eaa3a

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