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)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| scrapy-scraping-link-0.0.8.tar.gz | 4.5 kB | Without provenance | Details |
Release files / scrapy-scraping-link-0.0.8.tar.gz
| Download URL | scrapy-scraping-link-0.0.8.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2531809e27536bd872b3a25ae89324110b1a4d63049435586dbcbb721b843b13
|
|
BLAKE2b-256 checksum How to use checksums |
eb06939d5ec9d6f526a01fed0207078441c9f61661abdb5ed2d929f765840653
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.6.9
|
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.