Skip to main content

Scrapy ScrapingLink Middleware

Acknowledgements

Thanks to arimbr and ScrapingBee, this is adaptation of their work.

Installation

pip install scrapy-scraping-link

Configuration

Add your ScrapingLink_API_KEY and the ScrapingLinkMiddleware to your project settings.py. Don't forget to set CONCURRENT_REQUESTS according to your ScrapingLink plan.

SCRAPINGLINK_API_KEY = 'REPLACE-WITH-YOUR-API-KEY'

DOWNLOADER_MIDDLEWARES = {
    'scrapy_scraping_link.ScrapingLinkMiddleware': 700,
}

CONCURRENT_REQUESTS = 1

Usage

Inherit your spiders from ScrapingLinkSpider and yield a ScrapingLinkRequest.

Below you can see an example from the spider in parascrapear.py.

from scrapy import Spider
from scrapy_scraping_link import ScrapingLinkSpider, ScrapingLinkRequest


class ParascrapearSpider(Spider):
    name = 'parascrapear'
    allowed_domains = ['parascrapear.com']
    start_urls = ['http://parascrapear.com/']

    def parse(self, response):
        print('Parseando ' + response.url)       
        
        next_urls = response.css('a::attr(href)').getall()
        for next_url in next_urls:
            if next_url is not None:
                yield ScrapingLinkRequest(response.urljoin(next_url))
        
        sentences = response.css('q::text').getall()
        for sentence in sentences:
            print(sentence)

You can pass ScrapingLink parameters in the params argument of a ScrapingLinkRequest. Headers and cookies are passed like a normal Scrapy Request. ScrapingLinkRequests formats all parameters, headers and cookies to the format expected by the API.

Examples

Add your API key to settings.py.

To run the examples you need to clone this repository. In your terminal, go to examples/parascrapear/parascrapear and run the example spider with:

scrapy runspider parascrapear.py

Customer Support

Simply reach out to us via Telegram Group or or write us an email.

Sign up for our free plan to get a free API key loaded with 100 free credits. No credit card required!

Metadata

Release files for scrapy-scraping-link 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrapy-scraping-link 0.0.8
File Size Uploaded Provenance
scrapy-scraping-link-0.0.8.tar.gz 4.5 kB Without provenance Details

Security for scrapy-scraping-link 0.0.8

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.

Release history Release notifications | RSS feed

This release

0.0.8 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page