scrapely-python 0.1.0__py3-none-any.whl

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.
Files changed (43) hide show
  1. scrapely/__init__.py +246 -0
  2. scrapely/_browser_locations.py +5470 -0
  3. scrapely/actor.py +1836 -0
  4. scrapely/browser_configuration.py +146 -0
  5. scrapely/charging.py +1143 -0
  6. scrapely/charging_client.py +107 -0
  7. scrapely/configuration.py +375 -0
  8. scrapely/crypto/__init__.py +21 -0
  9. scrapely/crypto/_secrets.py +210 -0
  10. scrapely/errors.py +153 -0
  11. scrapely/events/__init__.py +57 -0
  12. scrapely/events/_types.py +194 -0
  13. scrapely/events/event_manager.py +292 -0
  14. scrapely/log.py +39 -0
  15. scrapely/patch_browser_pool.py +861 -0
  16. scrapely/pricing_types.py +172 -0
  17. scrapely/proxy_configuration.py +741 -0
  18. scrapely/py.typed +2 -0
  19. scrapely/request_loaders/__init__.py +5 -0
  20. scrapely/request_loaders/_scrapely_request_list.py +169 -0
  21. scrapely/storage/__init__.py +48 -0
  22. scrapely/storage/_file_system/__init__.py +9 -0
  23. scrapely/storage/_file_system/_key_value_store_client.py +155 -0
  24. scrapely/storage/_file_system/_storage_client.py +50 -0
  25. scrapely/storage/_metadata.py +138 -0
  26. scrapely/storage/api_client.py +350 -0
  27. scrapely/storage/client.py +618 -0
  28. scrapely/storage/patch_storage.py +257 -0
  29. scrapely/storage/scrapely_dataset_client.py +305 -0
  30. scrapely/storage/scrapely_kvs_client.py +220 -0
  31. scrapely/storage/scrapely_rq_client.py +496 -0
  32. scrapely/storage/scrapely_storage_client.py +192 -0
  33. scrapely/storage/smart_scrapely_storage_client.py +109 -0
  34. scrapely/storage/types.py +601 -0
  35. scrapely/storage/utils.py +38 -0
  36. scrapely/storage_clients/__init__.py +25 -0
  37. scrapely/storages/__init__.py +5 -0
  38. scrapely/types.py +269 -0
  39. scrapely/webhook.py +82 -0
  40. scrapely_python-0.1.0.dist-info/METADATA +83 -0
  41. scrapely_python-0.1.0.dist-info/RECORD +43 -0
  42. scrapely_python-0.1.0.dist-info/WHEEL +5 -0
  43. scrapely_python-0.1.0.dist-info/top_level.txt +1 -0
scrapely/__init__.py ADDED
@@ -0,0 +1,246 @@
1
+ """
2
+ Scrapely Python SDK - A toolkit for building Actors on the Scrapely platform.
3
+
4
+ Usage:
5
+ from scrapely import Actor, Dataset
6
+
7
+ async def main():
8
+ async with Actor:
9
+ actor_input = await Actor.get_input()
10
+ await Actor.push_data({'url': actor_input['url']})
11
+ """
12
+
13
+ # Side-effect: patch Crawlee Playwright browser pool to use remote CDP (CDP_URL).
14
+ # Must run on package import so `from scrapely import Actor` enables the patch
15
+ # before PlaywrightCrawler launches a browser (Node SDK parity).
16
+ from .patch_browser_pool import set_cdp_url # noqa: F401
17
+
18
+ from crawlee import Request
19
+
20
+ from crawlee.request_loaders import (
21
+ RequestLoader,
22
+ RequestManager,
23
+ RequestManagerTandem,
24
+ SitemapRequestLoader,
25
+ )
26
+ from crawlee.storages import Dataset, KeyValueStore, RequestQueue
27
+ from crawlee.storage_clients.models import DatasetItemsListPage
28
+
29
+ from .actor import Actor
30
+ from .configuration import Configuration
31
+ from .charging_client import (
32
+ USES_PUSH_DATA_INTERCEPTION,
33
+ create_charging_client,
34
+ push_data_charging_context,
35
+ )
36
+ from .storage import (
37
+ ApiStorageClient,
38
+ FileSystemStorageClient,
39
+ MemoryStorageClient,
40
+ ScrapelyStorageClient,
41
+ SmartScrapelyStorageClient,
42
+ StorageClient,
43
+ set_api_storage,
44
+ )
45
+ from .request_loaders import ScrapelyRequestList
46
+ from crawlee.events import EventListener
47
+ from .events import (
48
+ AbortingEvent,
49
+ ActorEventTypes,
50
+ CrawleeEventManager,
51
+ DeprecatedEvent,
52
+ Event,
53
+ EventAbortingData,
54
+ EventExitData,
55
+ EventManager,
56
+ EventMessage,
57
+ EventMigratingData,
58
+ EventPersistStateData,
59
+ EventSystemInfoData,
60
+ EventWithoutData,
61
+ ExitEvent,
62
+ LocalEventManager,
63
+ MigratingEvent,
64
+ PersistStateEvent,
65
+ ScrapelyEventManager,
66
+ SystemInfoEvent,
67
+ SystemInfoEventData,
68
+ UnknownEvent,
69
+ )
70
+ from .proxy_configuration import ProxyConfiguration
71
+ from .browser_configuration import BrowserConfiguration
72
+ from .charging import (
73
+ ChargingManager,
74
+ ChargeUncertainError,
75
+ ChargeRejectedError,
76
+ has_default_dataset_item_event_in_pricing,
77
+ is_default_dataset_item_event,
78
+ merge_charge_results,
79
+ push_data_and_charge,
80
+ resolve_default_dataset_item_event_name,
81
+ APIFY_DEFAULT_DATASET_ITEM_EVENT,
82
+ SCRAPELY_DEFAULT_DATASET_ITEM_EVENT,
83
+ DEFAULT_DATASET_ITEM_EVENT,
84
+ )
85
+
86
+ from .types import (
87
+ ActorInput,
88
+ ActorPermissionLevel,
89
+ ActorRun,
90
+ ApifyEnv,
91
+ AbortOptions,
92
+ CallOptions,
93
+ ExitOptions,
94
+ InitOptions,
95
+ MetamorphOptions,
96
+ OpenStorageOptions,
97
+ ProxyInfo,
98
+ RebootOptions,
99
+ RecordOptions,
100
+ SetStatusMessageOptions,
101
+ StartOptions,
102
+ WebhookOptions,
103
+ )
104
+
105
+ from .webhook import (
106
+ Webhook,
107
+ WebhookEventType,
108
+ )
109
+ from .pricing_types import (
110
+ PricingModel,
111
+ FreeActorPricingInfo,
112
+ FlatPricePerMonthActorPricingInfo,
113
+ PricePerDatasetItemActorPricingInfo,
114
+ PayPerEventActorPricingInfo,
115
+ PricingPerEvent,
116
+ ActorPricingInfo,
117
+ ActorChargeEvent,
118
+ ChargeResult,
119
+ ActorPricingInfoResult,
120
+ )
121
+ from .errors import (
122
+ ScrapelyClientError,
123
+ ScrapelyApiError,
124
+ InvalidResponseBodyError,
125
+ InvalidRequestError,
126
+ UnauthorizedError,
127
+ ForbiddenError,
128
+ NotFoundError,
129
+ ConflictError,
130
+ RateLimitError,
131
+ ServerError,
132
+ raise_for_status,
133
+ )
134
+
135
+ __version__ = '0.1.0'
136
+ __all__ = [
137
+ # Core
138
+ 'Actor',
139
+ 'Configuration',
140
+ 'set_cdp_url',
141
+ # ApifyClient
142
+ 'create_charging_client',
143
+ 'USES_PUSH_DATA_INTERCEPTION',
144
+ 'push_data_charging_context',
145
+
146
+ # Storage
147
+ 'Dataset',
148
+ 'KeyValueStore',
149
+ 'RequestQueue',
150
+ 'Request',
151
+ 'DatasetItemsListPage',
152
+ # Storage clients
153
+ 'ApiStorageClient',
154
+ 'ScrapelyStorageClient',
155
+ 'SmartScrapelyStorageClient',
156
+ 'FileSystemStorageClient',
157
+ 'MemoryStorageClient',
158
+ 'StorageClient',
159
+ 'set_api_storage',
160
+ # Request loaders
161
+ 'ScrapelyRequestList',
162
+ 'RequestLoader',
163
+ 'RequestManager',
164
+ 'RequestManagerTandem',
165
+ 'SitemapRequestLoader',
166
+ # Events
167
+ 'Event',
168
+ 'EventManager',
169
+ 'ScrapelyEventManager',
170
+ 'CrawleeEventManager',
171
+ 'LocalEventManager',
172
+ # Event data types
173
+ 'SystemInfoEventData',
174
+ 'EventAbortingData',
175
+ 'EventExitData',
176
+ 'EventListener',
177
+ 'EventMigratingData',
178
+ 'EventPersistStateData',
179
+ 'EventSystemInfoData',
180
+ # Event types
181
+ 'PersistStateEvent',
182
+ 'SystemInfoEvent',
183
+ 'MigratingEvent',
184
+ 'AbortingEvent',
185
+ 'ExitEvent',
186
+ 'EventWithoutData',
187
+ 'DeprecatedEvent',
188
+ 'UnknownEvent',
189
+ 'EventMessage',
190
+ 'ActorEventTypes',
191
+ # Proxy
192
+ 'ProxyConfiguration',
193
+ 'ProxyInfo',
194
+ # Remote browser
195
+ 'BrowserConfiguration',
196
+ # Charging
197
+ 'ChargingManager',
198
+ 'ChargeResult',
199
+ 'ChargeUncertainError',
200
+ 'ChargeRejectedError',
201
+ 'merge_charge_results',
202
+ 'push_data_and_charge',
203
+
204
+ # Types
205
+ 'ActorInput',
206
+ 'ActorPermissionLevel',
207
+ 'ActorRun',
208
+ 'ApifyEnv',
209
+ 'AbortOptions',
210
+ 'CallOptions',
211
+ 'ExitOptions',
212
+ 'InitOptions',
213
+ 'MetamorphOptions',
214
+ 'OpenStorageOptions',
215
+ 'RebootOptions',
216
+ 'RecordOptions',
217
+ 'SetStatusMessageOptions',
218
+ 'StartOptions',
219
+ 'WebhookOptions',
220
+
221
+ # Webhook
222
+ 'Webhook',
223
+ 'WebhookEventType',
224
+ # Pricing
225
+ 'PricingModel',
226
+ 'FreeActorPricingInfo',
227
+ 'FlatPricePerMonthActorPricingInfo',
228
+ 'PricePerDatasetItemActorPricingInfo',
229
+ 'PayPerEventActorPricingInfo',
230
+ 'PricingPerEvent',
231
+ 'ActorPricingInfo',
232
+ 'ActorChargeEvent',
233
+ 'ActorPricingInfoResult',
234
+ # Errors
235
+ 'ScrapelyClientError',
236
+ 'ScrapelyApiError',
237
+ 'InvalidResponseBodyError',
238
+ 'InvalidRequestError',
239
+ 'UnauthorizedError',
240
+ 'ForbiddenError',
241
+ 'NotFoundError',
242
+ 'ConflictError',
243
+ 'RateLimitError',
244
+ 'ServerError',
245
+ 'raise_for_status',
246
+ ]