Scrapy Executor avatar
Scrapy Executor

Deprecated

Pricing

Pay per usage

Go to Store
Scrapy Executor

Scrapy Executor

Deprecated

Developed by

Apify

Maintained by Community

Run Scrapy spiders written in Python on the Apify platform.

0.0 (0)

Pricing

Pay per usage

1

Total users

190

Monthly users

2

Runs succeeded

>99%

Last modified

2 years ago

You can access the Scrapy Executor programmatically from your own applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.

1from apify_client import ApifyClient
2
3# Initialize the ApifyClient with your Apify API token
4# Replace '<YOUR_API_TOKEN>' with your token.
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7# Prepare the Actor input
8run_input = { "scrapyCode": """import scrapy
9import apify
10 
11class MySpider(scrapy.Spider):
12 \tname = 'apifySpider'
13 
14 \tdef start_requests(self):
15 \t\turls = [
16 \t\t\t'https://apify.com',
17 \t\t\t'https://apify.com/store',
18 \t\t]
19 \t\tfor url in urls:
20 \t\t\tyield scrapy.Request(url=url, callback=self.parse)
21 
22 \tdef parse(self, response):
23 \t\turl = response.url
24 \t\ttitle = response.css('title::text').get()
25 \t\toutput = {
26 \t\t\t'url': url,
27 \t\t\t'title': title
28 \t\t}
29 \t\tapify.pushData(output)""" }
30
31# Run the Actor and wait for it to finish
32run = client.actor("apify/scrapy-executor").call(run_input=run_input)
33
34# Fetch and print Actor results from the run's dataset (if there are any)
35print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
36for item in client.dataset(run["defaultDatasetId"]).iterate_items():
37    print(item)
38
39# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

Scrapy Executor API in Python

The Apify API client for Python is the official library that allows you to use Scrapy Executor API in Python, providing convenience functions and automatic retries on errors.

Install the apify-client

pip install apify-client

Other API clients include: