apify 1.7.3b4__tar.gz → 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of apify might be problematic. Click here for more details.

Files changed (75) hide show
  1. apify-2.0.0/PKG-INFO +209 -0
  2. apify-2.0.0/README.md +171 -0
  3. apify-2.0.0/pyproject.toml +199 -0
  4. apify-2.0.0/src/apify/__init__.py +24 -0
  5. apify-2.0.0/src/apify/_actor.py +979 -0
  6. apify-2.0.0/src/apify/_configuration.py +310 -0
  7. apify-2.0.0/src/apify/_consts.py +10 -0
  8. {apify-1.7.3b4 → apify-2.0.0}/src/apify/_crypto.py +29 -27
  9. apify-2.0.0/src/apify/_models.py +110 -0
  10. apify-2.0.0/src/apify/_platform_event_manager.py +222 -0
  11. apify-2.0.0/src/apify/_proxy_configuration.py +316 -0
  12. apify-2.0.0/src/apify/_utils.py +25 -0
  13. apify-2.0.0/src/apify/apify_storage_client/__init__.py +3 -0
  14. apify-2.0.0/src/apify/apify_storage_client/_apify_storage_client.py +56 -0
  15. apify-2.0.0/src/apify/apify_storage_client/_dataset_client.py +188 -0
  16. apify-2.0.0/src/apify/apify_storage_client/_dataset_collection_client.py +50 -0
  17. apify-2.0.0/src/apify/apify_storage_client/_key_value_store_client.py +98 -0
  18. apify-2.0.0/src/apify/apify_storage_client/_key_value_store_collection_client.py +50 -0
  19. apify-2.0.0/src/apify/apify_storage_client/_request_queue_client.py +208 -0
  20. apify-2.0.0/src/apify/apify_storage_client/_request_queue_collection_client.py +50 -0
  21. apify-2.0.0/src/apify/log.py +43 -0
  22. apify-2.0.0/src/apify/py.typed +0 -0
  23. apify-2.0.0/src/apify/scrapy/__init__.py +11 -0
  24. apify-2.0.0/src/apify/scrapy/middlewares/__init__.py +3 -0
  25. {apify-1.7.3b4 → apify-2.0.0}/src/apify/scrapy/middlewares/apify_proxy.py +21 -21
  26. apify-2.0.0/src/apify/scrapy/middlewares/py.typed +0 -0
  27. apify-2.0.0/src/apify/scrapy/pipelines/__init__.py +3 -0
  28. {apify-1.7.3b4 → apify-2.0.0}/src/apify/scrapy/pipelines/actor_dataset_push.py +1 -1
  29. apify-2.0.0/src/apify/scrapy/pipelines/py.typed +0 -0
  30. apify-2.0.0/src/apify/scrapy/py.typed +0 -0
  31. {apify-1.7.3b4 → apify-2.0.0}/src/apify/scrapy/requests.py +55 -54
  32. {apify-1.7.3b4 → apify-2.0.0}/src/apify/scrapy/scheduler.py +19 -13
  33. {apify-1.7.3b4 → apify-2.0.0}/src/apify/scrapy/utils.py +2 -31
  34. apify-2.0.0/src/apify/storages/__init__.py +3 -0
  35. apify-2.0.0/src/apify/storages/py.typed +0 -0
  36. apify-1.7.3b4/PKG-INFO +0 -150
  37. apify-1.7.3b4/README.md +0 -90
  38. apify-1.7.3b4/pyproject.toml +0 -157
  39. apify-1.7.3b4/setup.cfg +0 -4
  40. apify-1.7.3b4/src/apify/__init__.py +0 -9
  41. apify-1.7.3b4/src/apify/_memory_storage/__init__.py +0 -3
  42. apify-1.7.3b4/src/apify/_memory_storage/file_storage_utils.py +0 -71
  43. apify-1.7.3b4/src/apify/_memory_storage/memory_storage_client.py +0 -219
  44. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/__init__.py +0 -19
  45. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/base_resource_client.py +0 -141
  46. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/base_resource_collection_client.py +0 -114
  47. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/dataset.py +0 -452
  48. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/dataset_collection.py +0 -48
  49. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/key_value_store.py +0 -533
  50. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/key_value_store_collection.py +0 -48
  51. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/request_queue.py +0 -466
  52. apify-1.7.3b4/src/apify/_memory_storage/resource_clients/request_queue_collection.py +0 -48
  53. apify-1.7.3b4/src/apify/_utils.py +0 -522
  54. apify-1.7.3b4/src/apify/actor.py +0 -1357
  55. apify-1.7.3b4/src/apify/config.py +0 -130
  56. apify-1.7.3b4/src/apify/consts.py +0 -67
  57. apify-1.7.3b4/src/apify/event_manager.py +0 -236
  58. apify-1.7.3b4/src/apify/log.py +0 -124
  59. apify-1.7.3b4/src/apify/proxy_configuration.py +0 -365
  60. apify-1.7.3b4/src/apify/scrapy/__init__.py +0 -3
  61. apify-1.7.3b4/src/apify/scrapy/middlewares/__init__.py +0 -1
  62. apify-1.7.3b4/src/apify/scrapy/pipelines/__init__.py +0 -1
  63. apify-1.7.3b4/src/apify/storages/__init__.py +0 -11
  64. apify-1.7.3b4/src/apify/storages/base_storage.py +0 -181
  65. apify-1.7.3b4/src/apify/storages/dataset.py +0 -494
  66. apify-1.7.3b4/src/apify/storages/key_value_store.py +0 -257
  67. apify-1.7.3b4/src/apify/storages/request_queue.py +0 -602
  68. apify-1.7.3b4/src/apify/storages/storage_client_manager.py +0 -72
  69. apify-1.7.3b4/src/apify.egg-info/PKG-INFO +0 -150
  70. apify-1.7.3b4/src/apify.egg-info/SOURCES.txt +0 -44
  71. apify-1.7.3b4/src/apify.egg-info/dependency_links.txt +0 -1
  72. apify-1.7.3b4/src/apify.egg-info/requires.txt +0 -35
  73. apify-1.7.3b4/src/apify.egg-info/top_level.txt +0 -1
  74. {apify-1.7.3b4 → apify-2.0.0}/LICENSE +0 -0
  75. {apify-1.7.3b4/src/apify → apify-2.0.0/src/apify/apify_storage_client}/py.typed +0 -0
apify-2.0.0/PKG-INFO ADDED
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.1
2
+ Name: apify
3
+ Version: 2.0.0
4
+ Summary: Apify SDK for Python
5
+ License: Apache-2.0
6
+ Keywords: apify,sdk,automation,chrome,crawlee,crawler,headless,scraper,scraping
7
+ Author: Apify Technologies s.r.o.
8
+ Author-email: support@apify.com
9
+ Requires-Python: >=3.9,<4.0
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Provides-Extra: scrapy
21
+ Requires-Dist: apify-client (>=1.7.1)
22
+ Requires-Dist: apify-shared (>=1.1.2)
23
+ Requires-Dist: crawlee (>=0.3.5)
24
+ Requires-Dist: cryptography (>=42.0.0)
25
+ Requires-Dist: httpx (>=0.27.0)
26
+ Requires-Dist: lazy-object-proxy (>=1.10.0)
27
+ Requires-Dist: scrapy (>=2.11.0) ; extra == "scrapy"
28
+ Requires-Dist: typing-extensions (>=4.1.0)
29
+ Requires-Dist: websockets (>=10.0)
30
+ Project-URL: Apify Homepage, https://apify.com
31
+ Project-URL: Changelog, https://docs.apify.com/sdk/python/docs/changelog
32
+ Project-URL: Documentation, https://docs.apify.com/sdk/python/
33
+ Project-URL: Homepage, https://docs.apify.com/sdk/python/
34
+ Project-URL: Issue Tracker, https://github.com/apify/apify-sdk-python/issues
35
+ Project-URL: Repository, https://github.com/apify/apify-sdk-python
36
+ Description-Content-Type: text/markdown
37
+
38
+ # Apify SDK for Python
39
+
40
+ The Apify SDK for Python is the official library to create [Apify Actors](https://docs.apify.com/platform/actors)
41
+ in Python. It provides useful features like Actor lifecycle management, local storage emulation, and Actor
42
+ event handling.
43
+
44
+ If you just need to access the [Apify API](https://docs.apify.com/api/v2) from your Python applications,
45
+ check out the [Apify Client for Python](https://docs.apify.com/api/client/python) instead.
46
+
47
+ ## Installation
48
+
49
+ The Apify SDK for Python is available on PyPI as the `apify` package.
50
+ For default installation, using Pip, run the following:
51
+
52
+ ```bash
53
+ pip install apify
54
+ ```
55
+
56
+ For users interested in integrating Apify with Scrapy, we provide a package extra called `scrapy`.
57
+ To install Apify with the `scrapy` extra, use the following command:
58
+
59
+ ```bash
60
+ pip install apify[scrapy]
61
+ ```
62
+
63
+ ## Documentation
64
+
65
+ For usage instructions, check the documentation on [Apify Docs](https://docs.apify.com/sdk/python/).
66
+
67
+ ## Examples
68
+
69
+ Below are few examples demonstrating how to use the Apify SDK with some web scraping-related libraries.
70
+
71
+ ### Apify SDK with HTTPX and BeautifulSoup
72
+
73
+ This example illustrates how to integrate the Apify SDK with [HTTPX](https://www.python-httpx.org/) and [BeautifulSoup](https://pypi.org/project/beautifulsoup4/) to scrape data from web pages.
74
+
75
+ ```python
76
+ from apify import Actor
77
+ from bs4 import BeautifulSoup
78
+ from httpx import AsyncClient
79
+
80
+
81
+ async def main() -> None:
82
+ async with Actor:
83
+ # Retrieve the Actor input, and use default values if not provided.
84
+ actor_input = await Actor.get_input() or {}
85
+ start_urls = actor_input.get('start_urls', [{'url': 'https://apify.com'}])
86
+
87
+ # Open the default request queue for handling URLs to be processed.
88
+ request_queue = await Actor.open_request_queue()
89
+
90
+ # Enqueue the start URLs.
91
+ for start_url in start_urls:
92
+ url = start_url.get('url')
93
+ await request_queue.add_request(url)
94
+
95
+ # Process the URLs from the request queue.
96
+ while request := await request_queue.fetch_next_request():
97
+ Actor.log.info(f'Scraping {request.url} ...')
98
+
99
+ # Fetch the HTTP response from the specified URL using HTTPX.
100
+ async with AsyncClient() as client:
101
+ response = await client.get(request.url)
102
+
103
+ # Parse the HTML content using Beautiful Soup.
104
+ soup = BeautifulSoup(response.content, 'html.parser')
105
+
106
+ # Extract the desired data.
107
+ data = {
108
+ 'url': actor_input['url'],
109
+ 'title': soup.title.string,
110
+ 'h1s': [h1.text for h1 in soup.find_all('h1')],
111
+ 'h2s': [h2.text for h2 in soup.find_all('h2')],
112
+ 'h3s': [h3.text for h3 in soup.find_all('h3')],
113
+ }
114
+
115
+ # Store the extracted data to the default dataset.
116
+ await Actor.push_data(data)
117
+ ```
118
+
119
+ ### Apify SDK with PlaywrightCrawler from Crawlee
120
+
121
+ This example demonstrates how to use the Apify SDK alongside `PlaywrightCrawler` from [Crawlee](https://crawlee.dev/python) to perform web scraping.
122
+
123
+ ```python
124
+ from apify import Actor, Request
125
+ from crawlee.playwright_crawler import PlaywrightCrawler, PlaywrightCrawlingContext
126
+
127
+
128
+ async def main() -> None:
129
+ async with Actor:
130
+ # Retrieve the Actor input, and use default values if not provided.
131
+ actor_input = await Actor.get_input() or {}
132
+ start_urls = [url.get('url') for url in actor_input.get('start_urls', [{'url': 'https://apify.com'}])]
133
+
134
+ # Exit if no start URLs are provided.
135
+ if not start_urls:
136
+ Actor.log.info('No start URLs specified in Actor input, exiting...')
137
+ await Actor.exit()
138
+
139
+ # Create a crawler.
140
+ crawler = PlaywrightCrawler(
141
+ # Limit the crawl to max requests. Remove or increase it for crawling all links.
142
+ max_requests_per_crawl=50,
143
+ headless=True,
144
+ )
145
+
146
+ # Define a request handler, which will be called for every request.
147
+ @crawler.router.default_handler
148
+ async def request_handler(context: PlaywrightCrawlingContext) -> None:
149
+ url = context.request.url
150
+ Actor.log.info(f'Scraping {url}...')
151
+
152
+ # Extract the desired data.
153
+ data = {
154
+ 'url': context.request.url,
155
+ 'title': await context.page.title(),
156
+ 'h1s': [await h1.text_content() for h1 in await context.page.locator('h1').all()],
157
+ 'h2s': [await h2.text_content() for h2 in await context.page.locator('h2').all()],
158
+ 'h3s': [await h3.text_content() for h3 in await context.page.locator('h3').all()],
159
+ }
160
+
161
+ # Store the extracted data to the default dataset.
162
+ await context.push_data(data)
163
+
164
+ # Enqueue additional links found on the current page.
165
+ await context.enqueue_links()
166
+
167
+ # Run the crawler with the starting URLs.
168
+ await crawler.run(start_urls)
169
+ ```
170
+
171
+ ## What are Actors?
172
+
173
+ Actors are serverless cloud programs that can do almost anything a human can do in a web browser.
174
+ They can do anything from small tasks such as filling in forms or unsubscribing from online services,
175
+ all the way up to scraping and processing vast numbers of web pages.
176
+
177
+ They can be run either locally, or on the [Apify platform](https://docs.apify.com/platform/),
178
+ where you can run them at scale, monitor them, schedule them, or publish and monetize them.
179
+
180
+ If you're new to Apify, learn [what is Apify](https://docs.apify.com/platform/about)
181
+ in the Apify platform documentation.
182
+
183
+ ## Creating Actors
184
+
185
+ To create and run Actors through Apify Console,
186
+ see the [Console documentation](https://docs.apify.com/academy/getting-started/creating-actors#choose-your-template).
187
+
188
+ To create and run Python Actors locally, check the documentation for
189
+ [how to create and run Python Actors locally](https://docs.apify.com/sdk/python/docs/overview/running-locally).
190
+
191
+ ## Guides
192
+
193
+ To see how you can use the Apify SDK with other popular libraries used for web scraping,
194
+ check out our guides for using
195
+ [Requests and HTTPX](https://docs.apify.com/sdk/python/docs/guides/requests-and-httpx),
196
+ [Beautiful Soup](https://docs.apify.com/sdk/python/docs/guides/beautiful-soup),
197
+ [Playwright](https://docs.apify.com/sdk/python/docs/guides/playwright),
198
+ [Selenium](https://docs.apify.com/sdk/python/docs/guides/selenium),
199
+ or [Scrapy](https://docs.apify.com/sdk/python/docs/guides/scrapy).
200
+
201
+ ## Usage concepts
202
+
203
+ To learn more about the features of the Apify SDK and how to use them,
204
+ check out the Usage Concepts section in the sidebar,
205
+ particularly the guides for the [Actor lifecycle](https://docs.apify.com/sdk/python/docs/concepts/actor-lifecycle),
206
+ [working with storages](https://docs.apify.com/sdk/python/docs/concepts/storages),
207
+ [handling Actor events](https://docs.apify.com/sdk/python/docs/concepts/actor-events)
208
+ or [how to use proxies](https://docs.apify.com/sdk/python/docs/concepts/proxy-management).
209
+
apify-2.0.0/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # Apify SDK for Python
2
+
3
+ The Apify SDK for Python is the official library to create [Apify Actors](https://docs.apify.com/platform/actors)
4
+ in Python. It provides useful features like Actor lifecycle management, local storage emulation, and Actor
5
+ event handling.
6
+
7
+ If you just need to access the [Apify API](https://docs.apify.com/api/v2) from your Python applications,
8
+ check out the [Apify Client for Python](https://docs.apify.com/api/client/python) instead.
9
+
10
+ ## Installation
11
+
12
+ The Apify SDK for Python is available on PyPI as the `apify` package.
13
+ For default installation, using Pip, run the following:
14
+
15
+ ```bash
16
+ pip install apify
17
+ ```
18
+
19
+ For users interested in integrating Apify with Scrapy, we provide a package extra called `scrapy`.
20
+ To install Apify with the `scrapy` extra, use the following command:
21
+
22
+ ```bash
23
+ pip install apify[scrapy]
24
+ ```
25
+
26
+ ## Documentation
27
+
28
+ For usage instructions, check the documentation on [Apify Docs](https://docs.apify.com/sdk/python/).
29
+
30
+ ## Examples
31
+
32
+ Below are few examples demonstrating how to use the Apify SDK with some web scraping-related libraries.
33
+
34
+ ### Apify SDK with HTTPX and BeautifulSoup
35
+
36
+ This example illustrates how to integrate the Apify SDK with [HTTPX](https://www.python-httpx.org/) and [BeautifulSoup](https://pypi.org/project/beautifulsoup4/) to scrape data from web pages.
37
+
38
+ ```python
39
+ from apify import Actor
40
+ from bs4 import BeautifulSoup
41
+ from httpx import AsyncClient
42
+
43
+
44
+ async def main() -> None:
45
+ async with Actor:
46
+ # Retrieve the Actor input, and use default values if not provided.
47
+ actor_input = await Actor.get_input() or {}
48
+ start_urls = actor_input.get('start_urls', [{'url': 'https://apify.com'}])
49
+
50
+ # Open the default request queue for handling URLs to be processed.
51
+ request_queue = await Actor.open_request_queue()
52
+
53
+ # Enqueue the start URLs.
54
+ for start_url in start_urls:
55
+ url = start_url.get('url')
56
+ await request_queue.add_request(url)
57
+
58
+ # Process the URLs from the request queue.
59
+ while request := await request_queue.fetch_next_request():
60
+ Actor.log.info(f'Scraping {request.url} ...')
61
+
62
+ # Fetch the HTTP response from the specified URL using HTTPX.
63
+ async with AsyncClient() as client:
64
+ response = await client.get(request.url)
65
+
66
+ # Parse the HTML content using Beautiful Soup.
67
+ soup = BeautifulSoup(response.content, 'html.parser')
68
+
69
+ # Extract the desired data.
70
+ data = {
71
+ 'url': actor_input['url'],
72
+ 'title': soup.title.string,
73
+ 'h1s': [h1.text for h1 in soup.find_all('h1')],
74
+ 'h2s': [h2.text for h2 in soup.find_all('h2')],
75
+ 'h3s': [h3.text for h3 in soup.find_all('h3')],
76
+ }
77
+
78
+ # Store the extracted data to the default dataset.
79
+ await Actor.push_data(data)
80
+ ```
81
+
82
+ ### Apify SDK with PlaywrightCrawler from Crawlee
83
+
84
+ This example demonstrates how to use the Apify SDK alongside `PlaywrightCrawler` from [Crawlee](https://crawlee.dev/python) to perform web scraping.
85
+
86
+ ```python
87
+ from apify import Actor, Request
88
+ from crawlee.playwright_crawler import PlaywrightCrawler, PlaywrightCrawlingContext
89
+
90
+
91
+ async def main() -> None:
92
+ async with Actor:
93
+ # Retrieve the Actor input, and use default values if not provided.
94
+ actor_input = await Actor.get_input() or {}
95
+ start_urls = [url.get('url') for url in actor_input.get('start_urls', [{'url': 'https://apify.com'}])]
96
+
97
+ # Exit if no start URLs are provided.
98
+ if not start_urls:
99
+ Actor.log.info('No start URLs specified in Actor input, exiting...')
100
+ await Actor.exit()
101
+
102
+ # Create a crawler.
103
+ crawler = PlaywrightCrawler(
104
+ # Limit the crawl to max requests. Remove or increase it for crawling all links.
105
+ max_requests_per_crawl=50,
106
+ headless=True,
107
+ )
108
+
109
+ # Define a request handler, which will be called for every request.
110
+ @crawler.router.default_handler
111
+ async def request_handler(context: PlaywrightCrawlingContext) -> None:
112
+ url = context.request.url
113
+ Actor.log.info(f'Scraping {url}...')
114
+
115
+ # Extract the desired data.
116
+ data = {
117
+ 'url': context.request.url,
118
+ 'title': await context.page.title(),
119
+ 'h1s': [await h1.text_content() for h1 in await context.page.locator('h1').all()],
120
+ 'h2s': [await h2.text_content() for h2 in await context.page.locator('h2').all()],
121
+ 'h3s': [await h3.text_content() for h3 in await context.page.locator('h3').all()],
122
+ }
123
+
124
+ # Store the extracted data to the default dataset.
125
+ await context.push_data(data)
126
+
127
+ # Enqueue additional links found on the current page.
128
+ await context.enqueue_links()
129
+
130
+ # Run the crawler with the starting URLs.
131
+ await crawler.run(start_urls)
132
+ ```
133
+
134
+ ## What are Actors?
135
+
136
+ Actors are serverless cloud programs that can do almost anything a human can do in a web browser.
137
+ They can do anything from small tasks such as filling in forms or unsubscribing from online services,
138
+ all the way up to scraping and processing vast numbers of web pages.
139
+
140
+ They can be run either locally, or on the [Apify platform](https://docs.apify.com/platform/),
141
+ where you can run them at scale, monitor them, schedule them, or publish and monetize them.
142
+
143
+ If you're new to Apify, learn [what is Apify](https://docs.apify.com/platform/about)
144
+ in the Apify platform documentation.
145
+
146
+ ## Creating Actors
147
+
148
+ To create and run Actors through Apify Console,
149
+ see the [Console documentation](https://docs.apify.com/academy/getting-started/creating-actors#choose-your-template).
150
+
151
+ To create and run Python Actors locally, check the documentation for
152
+ [how to create and run Python Actors locally](https://docs.apify.com/sdk/python/docs/overview/running-locally).
153
+
154
+ ## Guides
155
+
156
+ To see how you can use the Apify SDK with other popular libraries used for web scraping,
157
+ check out our guides for using
158
+ [Requests and HTTPX](https://docs.apify.com/sdk/python/docs/guides/requests-and-httpx),
159
+ [Beautiful Soup](https://docs.apify.com/sdk/python/docs/guides/beautiful-soup),
160
+ [Playwright](https://docs.apify.com/sdk/python/docs/guides/playwright),
161
+ [Selenium](https://docs.apify.com/sdk/python/docs/guides/selenium),
162
+ or [Scrapy](https://docs.apify.com/sdk/python/docs/guides/scrapy).
163
+
164
+ ## Usage concepts
165
+
166
+ To learn more about the features of the Apify SDK and how to use them,
167
+ check out the Usage Concepts section in the sidebar,
168
+ particularly the guides for the [Actor lifecycle](https://docs.apify.com/sdk/python/docs/concepts/actor-lifecycle),
169
+ [working with storages](https://docs.apify.com/sdk/python/docs/concepts/storages),
170
+ [handling Actor events](https://docs.apify.com/sdk/python/docs/concepts/actor-events)
171
+ or [how to use proxies](https://docs.apify.com/sdk/python/docs/concepts/proxy-management).
@@ -0,0 +1,199 @@
1
+ [build-system]
2
+ requires = ["poetry-core"]
3
+ build-backend = "poetry.core.masonry.api"
4
+
5
+ [tool.poetry]
6
+ name = "apify"
7
+ version = "2.0.0"
8
+ description = "Apify SDK for Python"
9
+ authors = ["Apify Technologies s.r.o. <support@apify.com>"]
10
+ license = "Apache-2.0"
11
+ readme = "README.md"
12
+ packages = [{ include = "apify", from = "src" }]
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: Apache Software License",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3.9",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Software Development :: Libraries",
23
+ ]
24
+ keywords = [
25
+ "apify",
26
+ "sdk",
27
+ "automation",
28
+ "chrome",
29
+ "crawlee",
30
+ "crawler",
31
+ "headless",
32
+ "scraper",
33
+ "scraping",
34
+ ]
35
+
36
+ [tool.poetry.urls]
37
+ "Homepage" = "https://docs.apify.com/sdk/python/"
38
+ "Apify Homepage" = "https://apify.com"
39
+ "Changelog" = "https://docs.apify.com/sdk/python/docs/changelog"
40
+ "Documentation" = "https://docs.apify.com/sdk/python/"
41
+ "Issue Tracker" = "https://github.com/apify/apify-sdk-python/issues"
42
+ "Repository" = "https://github.com/apify/apify-sdk-python"
43
+
44
+ # We use inclusive ordered comparison clauses for external packages intentionally in order to enhance SDK's
45
+ # compatibility with external packages. This decision was discussed in detail in the following PR:
46
+ # https://github.com/apify/apify-sdk-python/pull/154.
47
+ [tool.poetry.dependencies]
48
+ python = "^3.9"
49
+ apify-client = ">=1.7.1"
50
+ apify-shared = ">=1.1.2"
51
+ crawlee = ">=0.3.5"
52
+ cryptography = ">=42.0.0"
53
+ httpx = ">=0.27.0"
54
+ lazy-object-proxy = ">=1.10.0"
55
+ scrapy = { version = ">=2.11.0", optional = true }
56
+ typing-extensions = ">=4.1.0"
57
+ websockets = ">=10.0"
58
+
59
+ [tool.poetry.group.dev.dependencies]
60
+ build = "~1.2.0"
61
+ filelock = "~3.16.0"
62
+ griffe = "~1.2.0"
63
+ mypy = "~1.11.0"
64
+ pre-commit = "~3.8.0"
65
+ pydoc-markdown = "~4.8.0"
66
+ pytest = "~8.3.0"
67
+ pytest-asyncio = "~0.24.0"
68
+ pytest-cov = "~5.0.0"
69
+ pytest-only = "~2.1.0"
70
+ pytest-timeout = "~2.3.0"
71
+ pytest-xdist = "~3.6.0"
72
+ respx = "~0.21.0"
73
+ ruff = "~0.6.0"
74
+ setuptools = "~74.0.0" # setuptools are used by pytest but not explicitly required
75
+
76
+ [tool.poetry.extras]
77
+ scrapy = ["scrapy"]
78
+
79
+ [tool.ruff]
80
+ line-length = 120
81
+
82
+ [tool.ruff.lint]
83
+ select = ["ALL"]
84
+ ignore = [
85
+ "ANN101", # Missing type annotation for `self` in method
86
+ "ANN102", # Missing type annotation for `{name}` in classmethod
87
+ "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {filename}
88
+ "ASYNC109", # Async function definition with a `timeout` parameter
89
+ "BLE001", # Do not catch blind exception
90
+ "C901", # `{name}` is too complex
91
+ "COM812", # This rule may cause conflicts when used with the formatter
92
+ "D100", # Missing docstring in public module
93
+ "D104", # Missing docstring in public package
94
+ "D107", # Missing docstring in `__init__`
95
+ "EM", # flake8-errmsg
96
+ "G004", # Logging statement uses f-string
97
+ "ISC001", # This rule may cause conflicts when used with the formatter
98
+ "FIX", # flake8-fixme
99
+ "PGH003", # Use specific rule codes when ignoring type issues
100
+ "PLR0911", # Too many return statements
101
+ "PLR0913", # Too many arguments in function definition
102
+ "PLR0915", # Too many statements
103
+ "PTH", # flake8-use-pathlib
104
+ "PYI034", # `__aenter__` methods in classes like `{name}` usually return `self` at runtime
105
+ "PYI036", # The second argument in `__aexit__` should be annotated with `object` or `BaseException | None`
106
+ "S102", # Use of `exec` detected
107
+ "S105", # Possible hardcoded password assigned to
108
+ "S106", # Possible hardcoded password assigned to argument: "{name}"
109
+ "S301", # `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
110
+ "S303", # Use of insecure MD2, MD4, MD5, or SHA1 hash function
111
+ "S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
112
+ "TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...` or `# TODO @<author_name>: ...
113
+ "TRY003", # Avoid specifying long messages outside the exception class
114
+ ]
115
+
116
+ [tool.ruff.format]
117
+ quote-style = "single"
118
+ indent-style = "space"
119
+
120
+ [tool.ruff.lint.per-file-ignores]
121
+ "**/__init__.py" = [
122
+ "F401", # Unused imports
123
+ ]
124
+ "**/{scripts}/*" = [
125
+ "D", # Everything from the pydocstyle
126
+ "INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
127
+ "PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
128
+ "T20", # flake8-print
129
+ ]
130
+ "**/{tests}/*" = [
131
+ "D", # Everything from the pydocstyle
132
+ "INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
133
+ "PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
134
+ "S101", # Use of assert detected
135
+ "SLF001", # Private member accessed: `{name}`
136
+ "T20", # flake8-print
137
+ "TRY301", # Abstract `raise` to an inner function
138
+ "TID252", # Prefer absolute imports over relative imports from parent modules
139
+ ]
140
+ "**/{docs}/**" = [
141
+ "D", # Everything from the pydocstyle
142
+ "INP001", # File {filename} is part of an implicit namespace package, add an __init__.py
143
+ "F841", # Local variable {variable} is assigned to but never used
144
+ ]
145
+
146
+ [tool.ruff.lint.flake8-quotes]
147
+ docstring-quotes = "double"
148
+ inline-quotes = "single"
149
+
150
+ [tool.ruff.lint.flake8-builtins]
151
+ builtins-ignorelist = ["id"]
152
+
153
+ [tool.ruff.lint.pydocstyle]
154
+ convention = "google"
155
+
156
+ [tool.ruff.lint.isort]
157
+ known-local-folder = ["apify"]
158
+ known-first-party = ["apify_client", "apify_shared", "crawlee"]
159
+
160
+ [tool.ruff.lint.pylint]
161
+ max-branches = 18
162
+
163
+ [tool.pytest.ini_options]
164
+ addopts = "-ra"
165
+ asyncio_mode = "auto"
166
+ timeout = 1200
167
+
168
+ [tool.mypy]
169
+ python_version = "3.9"
170
+ plugins = ["pydantic.mypy"]
171
+ files = ["scripts", "src", "tests"]
172
+ check_untyped_defs = true
173
+ disallow_incomplete_defs = true
174
+ disallow_untyped_calls = true
175
+ disallow_untyped_decorators = true
176
+ disallow_untyped_defs = true
177
+ no_implicit_optional = true
178
+ warn_redundant_casts = true
179
+ warn_return_any = true
180
+ warn_unreachable = true
181
+ warn_unused_ignores = true
182
+ exclude = []
183
+
184
+ [[tool.mypy.overrides]]
185
+ module = ['scrapy', 'scrapy.*', 'lazy_object_proxy']
186
+ ignore_missing_imports = true
187
+
188
+ [tool.coverage.report]
189
+ exclude_lines = [
190
+ "pragma: no cover",
191
+ "if TYPE_CHECKING:",
192
+ "assert_never()"
193
+ ]
194
+
195
+ [tool.basedpyright]
196
+ typeCheckingMode = "standard"
197
+
198
+ [tool.ipdb]
199
+ context = 7
@@ -0,0 +1,24 @@
1
+ from importlib import metadata
2
+
3
+ from apify_shared.consts import WebhookEventType
4
+ from crawlee import Request
5
+ from crawlee.events._types import Event
6
+
7
+ from apify._actor import Actor
8
+ from apify._configuration import Configuration
9
+ from apify._models import Webhook
10
+ from apify._proxy_configuration import ProxyConfiguration, ProxyInfo
11
+
12
+ __version__ = metadata.version('apify')
13
+
14
+ __all__ = [
15
+ 'Actor',
16
+ 'Event',
17
+ 'Configuration',
18
+ 'ProxyConfiguration',
19
+ 'ProxyInfo',
20
+ 'Request',
21
+ 'Webhook',
22
+ 'WebhookEventType',
23
+ '__version__',
24
+ ]