raspbytes 1.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.
- raspbytes/__init__.py +87 -0
- raspbytes/_core/__init__.py +1 -0
- raspbytes/_core/constants.py +38 -0
- raspbytes/_core/http.py +160 -0
- raspbytes/_core/transport.py +175 -0
- raspbytes/_core/types.py +11 -0
- raspbytes/_core/version.py +8 -0
- raspbytes/client.py +88 -0
- raspbytes/config.py +122 -0
- raspbytes/countries.py +278 -0
- raspbytes/exceptions.py +115 -0
- raspbytes/managed_scrapers.py +4 -0
- raspbytes/models.py +89 -0
- raspbytes/py.typed +1 -0
- raspbytes/resources/__init__.py +17 -0
- raspbytes/resources/_base.py +75 -0
- raspbytes/resources/_polling.py +73 -0
- raspbytes/resources/browser.py +185 -0
- raspbytes/resources/proxies.py +49 -0
- raspbytes/resources/scraper/__init__.py +45 -0
- raspbytes/resources/scraper/_generated/__init__.py +1 -0
- raspbytes/resources/scraper/_generated/managed.py +190 -0
- raspbytes/resources/scraper/_generated/wire.py +632 -0
- raspbytes/resources/scraper/_managed.py +14 -0
- raspbytes/resources/scraper/_request.py +128 -0
- raspbytes/resources/scraper/builder.py +199 -0
- raspbytes/resources/scraper/hub.py +168 -0
- raspbytes/resources/scraper/monitoring.py +132 -0
- raspbytes/resources/scraper/runs.py +202 -0
- raspbytes/resources/scraper/schedules.py +172 -0
- raspbytes/resources/scraper/storage.py +155 -0
- raspbytes/resources/scraper/tasks.py +134 -0
- raspbytes/resources/scraper/types.py +96 -0
- raspbytes/resources/unblocker.py +131 -0
- raspbytes/scraper_types.py +4 -0
- raspbytes-1.1.0.dist-info/METADATA +297 -0
- raspbytes-1.1.0.dist-info/RECORD +39 -0
- raspbytes-1.1.0.dist-info/WHEEL +4 -0
- raspbytes-1.1.0.dist-info/licenses/LICENSE +25 -0
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
# Generated from schemas/scraper-api.json by scripts/generate_scraper_contract.py.
|
|
2
|
+
|
|
3
|
+
from typing import Literal, NotRequired, TypedDict
|
|
4
|
+
|
|
5
|
+
from ...._core.types import JSONValue
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ScraperRoute:
|
|
9
|
+
CREATOR_SCRAPER_REVISIONS_CREATE = "scrape/creator/scrapers/{scraper_id}/revisions/"
|
|
10
|
+
CREATOR_SCRAPER_REVISIONS_LIST = "scrape/creator/scrapers/{scraper_id}/revisions/"
|
|
11
|
+
CREATOR_SCRAPER_SHARES_CREATE = "scrape/creator/scrapers/{scraper_id}/shares/"
|
|
12
|
+
CREATOR_SCRAPER_SHARES_REVOKE = "scrape/creator/scrapers/{scraper_id}/shares/{share_id}/"
|
|
13
|
+
CREATOR_SCRAPERS_ARCHIVE = "scrape/creator/scrapers/{scraper_id}/"
|
|
14
|
+
CREATOR_SCRAPERS_CREATE = "scrape/creator/scrapers/"
|
|
15
|
+
CREATOR_SCRAPERS_LIST = "scrape/creator/scrapers/"
|
|
16
|
+
CREATOR_SCRAPERS_PUBLISH = "scrape/creator/scrapers/{scraper_id}/publication/"
|
|
17
|
+
CREATOR_SCRAPERS_RETRIEVE = "scrape/creator/scrapers/{scraper_id}/"
|
|
18
|
+
CREATOR_SCRAPERS_UNPUBLISH = "scrape/creator/scrapers/{scraper_id}/publication/"
|
|
19
|
+
CREATOR_SCRAPERS_UPDATE = "scrape/creator/scrapers/{scraper_id}/"
|
|
20
|
+
SCRAPER_ARTIFACT_DOWNLOAD = "scrape/artifacts/{artifact_id}/download/"
|
|
21
|
+
SCRAPER_ARTIFACTS_LIST = "scrape/artifacts/"
|
|
22
|
+
SCRAPER_HUB_LIST = "scrape/hub/"
|
|
23
|
+
SCRAPER_HUB_RETRIEVE = "scrape/hub/{scraper_id}/"
|
|
24
|
+
SCRAPER_HUB_RUN_CREATE = "scrape/hub/{scraper_id}/runs/"
|
|
25
|
+
SCRAPER_MONITOR_POLICY_EVALUATE = "scrape/monitoring/policy/"
|
|
26
|
+
SCRAPER_MONITOR_POLICY_RETRIEVE = "scrape/monitoring/policy/"
|
|
27
|
+
SCRAPER_MONITOR_POLICY_UPDATE = "scrape/monitoring/policy/"
|
|
28
|
+
SCRAPER_MONITORING_RETRIEVE = "scrape/monitoring/"
|
|
29
|
+
SCRAPER_MONITORING_SCOPES_LIST = "scrape/monitoring/scopes/"
|
|
30
|
+
SCRAPER_REQUEST_ARTIFACTS_LIST = "scrape/requests/{request_id}/artifacts/"
|
|
31
|
+
SCRAPER_REQUESTS_CANCEL = "scrape/requests/{request_id}/"
|
|
32
|
+
SCRAPER_REQUESTS_CREATE = "scrape/requests/"
|
|
33
|
+
SCRAPER_REQUESTS_LIST = "scrape/requests/"
|
|
34
|
+
SCRAPER_REQUESTS_RETRIEVE = "scrape/requests/{request_id}/"
|
|
35
|
+
SCRAPER_SCHEDULES_CREATE = "scrape/schedules/"
|
|
36
|
+
SCRAPER_SCHEDULES_LIST = "scrape/schedules/"
|
|
37
|
+
SCRAPER_SCHEDULES_PAUSE = "scrape/schedules/{schedule_id}/"
|
|
38
|
+
SCRAPER_SCHEDULES_RETRIEVE = "scrape/schedules/{schedule_id}/"
|
|
39
|
+
SCRAPER_SCHEDULES_RUN_NOW = "scrape/schedules/{schedule_id}/run/"
|
|
40
|
+
SCRAPER_SCHEDULES_UPDATE = "scrape/schedules/{schedule_id}/"
|
|
41
|
+
SCRAPER_SUBMIT_CONVENIENCE = "scrape/"
|
|
42
|
+
SCRAPING_TASK_REVISIONS_CREATE = "scrape/tasks/{task_id}/revisions/"
|
|
43
|
+
SCRAPING_TASK_REVISIONS_LIST = "scrape/tasks/{task_id}/revisions/"
|
|
44
|
+
SCRAPING_TASKS_ARCHIVE = "scrape/tasks/{task_id}/"
|
|
45
|
+
SCRAPING_TASKS_CREATE = "scrape/tasks/"
|
|
46
|
+
SCRAPING_TASKS_LIST = "scrape/tasks/"
|
|
47
|
+
SCRAPING_TASKS_RETRIEVE = "scrape/tasks/{task_id}/"
|
|
48
|
+
SCRAPING_TASKS_RUN = "scrape/tasks/{task_id}/runs/"
|
|
49
|
+
SCRAPING_TASKS_UPDATE = "scrape/tasks/{task_id}/"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
AvailabilityEnum = Literal["available", "unavailable"]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class CreatorScraperCreate(TypedDict):
|
|
56
|
+
name: str
|
|
57
|
+
slug: NotRequired[str]
|
|
58
|
+
description: NotRequired[str]
|
|
59
|
+
category: NotRequired[str]
|
|
60
|
+
tags: NotRequired[list[str]]
|
|
61
|
+
revision: NotRequired["CreatorScraperRevisionCreate"]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class CreatorScraperResponse(TypedDict):
|
|
65
|
+
id: str
|
|
66
|
+
slug: str
|
|
67
|
+
name: str
|
|
68
|
+
description: str
|
|
69
|
+
category: str
|
|
70
|
+
tags: list[str]
|
|
71
|
+
visibility: str
|
|
72
|
+
status: str
|
|
73
|
+
verified: bool
|
|
74
|
+
listed: bool
|
|
75
|
+
execution_enabled: bool
|
|
76
|
+
availability: AvailabilityEnum
|
|
77
|
+
availability_reason: str
|
|
78
|
+
current_revision: int
|
|
79
|
+
revision: "CreatorScraperRevisionResponse | None"
|
|
80
|
+
revision_count: int
|
|
81
|
+
shares: "list[CreatorScraperShareResponse]"
|
|
82
|
+
created_at: str
|
|
83
|
+
updated_at: str
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class CreatorScraperRevisionCreate(TypedDict):
|
|
87
|
+
configuration: "SavedScraperDefinition"
|
|
88
|
+
input_schema: NotRequired["SavedScraperInputSchema"]
|
|
89
|
+
output_schema: NotRequired[dict[str, JSONValue]]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class CreatorScraperRevisionResponse(TypedDict):
|
|
93
|
+
id: str
|
|
94
|
+
revision: int
|
|
95
|
+
configuration: dict[str, JSONValue]
|
|
96
|
+
input_schema: dict[str, JSONValue]
|
|
97
|
+
output_schema: dict[str, JSONValue]
|
|
98
|
+
created_at: str
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class CreatorScraperShareCreate(TypedDict):
|
|
102
|
+
email: str
|
|
103
|
+
role: NotRequired["RoleEnum"]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class CreatorScraperShareResponse(TypedDict):
|
|
107
|
+
id: str
|
|
108
|
+
email: str
|
|
109
|
+
role: str
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
DestinationEnum = Literal["path", "query"]
|
|
113
|
+
|
|
114
|
+
HealthEnum = Literal["healthy", "paused", "degraded", "never_run"]
|
|
115
|
+
|
|
116
|
+
KindEnum = Literal["raspbytes", "creator"]
|
|
117
|
+
|
|
118
|
+
MergeEnum = Literal["replace_if_present", "fill_missing", "append_unique"]
|
|
119
|
+
|
|
120
|
+
MethodEnum = Literal["GET", "POST"]
|
|
121
|
+
|
|
122
|
+
OverlapPolicyEnum = Literal["skip", "allow"]
|
|
123
|
+
|
|
124
|
+
OwnershipEnum = Literal["raspbytes", "mine"]
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class PatchedCreatorScraperUpdate(TypedDict, total=False):
|
|
128
|
+
name: str
|
|
129
|
+
description: str
|
|
130
|
+
category: str
|
|
131
|
+
tags: list[str]
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class PatchedScraperMonitorPolicyUpdate(TypedDict, total=False):
|
|
135
|
+
enabled: bool
|
|
136
|
+
window_minutes: "WindowMinutesEnum"
|
|
137
|
+
minimum_samples: int
|
|
138
|
+
minimum_success_rate: str
|
|
139
|
+
maximum_failure_rate: str
|
|
140
|
+
maximum_p95_latency_ms: int
|
|
141
|
+
webhook_url: str
|
|
142
|
+
notify_on_breach: bool
|
|
143
|
+
notify_on_recovery: bool
|
|
144
|
+
repeat_after_minutes: int
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class PatchedScraperScheduleUpdate(TypedDict, total=False):
|
|
148
|
+
version: int
|
|
149
|
+
name: str
|
|
150
|
+
enabled: bool
|
|
151
|
+
frequency: "RecurringScheduleFrequencyEnum"
|
|
152
|
+
timezone: str
|
|
153
|
+
time_of_day: str
|
|
154
|
+
weekdays: list[int]
|
|
155
|
+
month_day: int | None
|
|
156
|
+
overlap_policy: OverlapPolicyEnum
|
|
157
|
+
inputs: dict[str, str]
|
|
158
|
+
request_overrides: "ScraperScheduleRequestOverrides"
|
|
159
|
+
webhook_url: str
|
|
160
|
+
notify_on_success: bool
|
|
161
|
+
notify_on_failure: bool
|
|
162
|
+
failure_threshold: int
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class PatchedScrapingTaskUpdate(TypedDict, total=False):
|
|
166
|
+
name: str
|
|
167
|
+
description: str
|
|
168
|
+
status: "ScrapingTaskStatusEnum"
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
PathTransformEnum = Literal["slug"]
|
|
172
|
+
|
|
173
|
+
RecurringScheduleFrequencyEnum = Literal["daily", "weekly", "monthly", "custom"]
|
|
174
|
+
|
|
175
|
+
ResponseFormatEnum = Literal["json", "markdown"]
|
|
176
|
+
|
|
177
|
+
RoleEnum = Literal["use"]
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class SavedScraperDefinition(TypedDict):
|
|
181
|
+
url: NotRequired[str]
|
|
182
|
+
method: NotRequired[MethodEnum]
|
|
183
|
+
country: NotRequired[str]
|
|
184
|
+
locale: NotRequired[str]
|
|
185
|
+
response_format: NotRequired[ResponseFormatEnum]
|
|
186
|
+
render_js: NotRequired[bool]
|
|
187
|
+
extractor: "ScrapeExtractor"
|
|
188
|
+
follow_redirects: NotRequired[bool]
|
|
189
|
+
timeout_ms: NotRequired[int]
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class SavedScraperInputOption(TypedDict):
|
|
193
|
+
value: str
|
|
194
|
+
label: NotRequired[str]
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
class SavedScraperInputParameter(TypedDict):
|
|
198
|
+
name: str
|
|
199
|
+
label: NotRequired[str]
|
|
200
|
+
description: NotRequired[str]
|
|
201
|
+
placeholder: NotRequired[str]
|
|
202
|
+
destination: NotRequired[DestinationEnum]
|
|
203
|
+
query_name: NotRequired[str]
|
|
204
|
+
source_name: NotRequired[str]
|
|
205
|
+
required: NotRequired[bool]
|
|
206
|
+
multiple: NotRequired[bool]
|
|
207
|
+
type: NotRequired["SavedScraperInputParameterTypeEnum"]
|
|
208
|
+
path_transform: NotRequired[PathTransformEnum]
|
|
209
|
+
options: NotRequired[list[SavedScraperInputOption]]
|
|
210
|
+
optional_for_path_patterns: NotRequired[list[str]]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
SavedScraperInputParameterTypeEnum = Literal["string", "text", "search", "number", "boolean"]
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
class SavedScraperInputSchema(TypedDict, total=False):
|
|
217
|
+
path_template: str
|
|
218
|
+
query_parameters: list[SavedScraperInputParameter]
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
ScopeEnum = Literal["record", "document"]
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class ScrapeExtractionField(TypedDict):
|
|
225
|
+
selector: str
|
|
226
|
+
source: NotRequired["ScrapeExtractionSourceEnum"]
|
|
227
|
+
attribute: NotRequired[str]
|
|
228
|
+
multiple: NotRequired[bool]
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
ScrapeExtractionSourceEnum = Literal["css", "xpath", "json"]
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class ScrapeExtractor(TypedDict, total=False):
|
|
235
|
+
parser: str
|
|
236
|
+
fields: dict[str, ScrapeExtractionField]
|
|
237
|
+
record_selector: "ScrapeRecordSelector"
|
|
238
|
+
pagination: "ScrapePagination"
|
|
239
|
+
follow: "ScrapeFollow"
|
|
240
|
+
reveals: "list[ScrapeReveal]"
|
|
241
|
+
inputs: dict[str, str]
|
|
242
|
+
max_records: int
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
class ScrapeFollow(TypedDict):
|
|
246
|
+
source: NotRequired["ScrapeHtmlSourceEnum"]
|
|
247
|
+
selector: str
|
|
248
|
+
attribute: NotRequired[str]
|
|
249
|
+
fields: dict[str, ScrapeExtractionField]
|
|
250
|
+
limit: NotRequired[int]
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
ScrapeHtmlSourceEnum = Literal["css", "xpath"]
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
class ScrapeJobPage(TypedDict):
|
|
257
|
+
next: str | None
|
|
258
|
+
previous: str | None
|
|
259
|
+
results: "list[ScrapeJobResponse]"
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class ScrapeJobResponse(TypedDict):
|
|
263
|
+
id: str
|
|
264
|
+
status: str
|
|
265
|
+
response_format: ResponseFormatEnum
|
|
266
|
+
schema: dict[str, JSONValue]
|
|
267
|
+
requested_at: str
|
|
268
|
+
completed_at: str | None
|
|
269
|
+
request: dict[str, JSONValue]
|
|
270
|
+
usage: dict[str, JSONValue]
|
|
271
|
+
summary: dict[str, JSONValue]
|
|
272
|
+
warnings: list[dict[str, JSONValue]]
|
|
273
|
+
error: JSONValue
|
|
274
|
+
result: NotRequired[JSONValue]
|
|
275
|
+
artifacts: NotRequired[list[dict[str, JSONValue]]]
|
|
276
|
+
schedule: NotRequired[dict[str, JSONValue]]
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
class ScrapePagination(TypedDict):
|
|
280
|
+
source: NotRequired[ScrapeHtmlSourceEnum]
|
|
281
|
+
selector: str
|
|
282
|
+
attribute: NotRequired[str]
|
|
283
|
+
limit: NotRequired[int]
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class ScrapeRecordSelector(TypedDict):
|
|
287
|
+
source: NotRequired[ScrapeHtmlSourceEnum]
|
|
288
|
+
selector: str
|
|
289
|
+
limit: NotRequired[int]
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class ScrapeRequest(TypedDict):
|
|
293
|
+
url: NotRequired[str]
|
|
294
|
+
method: NotRequired[MethodEnum]
|
|
295
|
+
headers: NotRequired[dict[str, JSONValue]]
|
|
296
|
+
body: NotRequired[str]
|
|
297
|
+
country: NotRequired[str]
|
|
298
|
+
locale: NotRequired[str]
|
|
299
|
+
response_format: NotRequired[ResponseFormatEnum]
|
|
300
|
+
render_js: NotRequired[bool]
|
|
301
|
+
extractor: ScrapeExtractor
|
|
302
|
+
follow_redirects: NotRequired[bool]
|
|
303
|
+
timeout_ms: NotRequired[int]
|
|
304
|
+
idempotency_key: NotRequired[str]
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
class ScrapeReveal(TypedDict):
|
|
308
|
+
id: str
|
|
309
|
+
trigger: "ScrapeRevealSelector"
|
|
310
|
+
content: "ScrapeRevealContent"
|
|
311
|
+
restore: NotRequired["ScrapeRevealSelector"]
|
|
312
|
+
fields: "dict[str, ScrapeRevealField]"
|
|
313
|
+
timeout_ms: NotRequired[int]
|
|
314
|
+
limit: NotRequired[int]
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
class ScrapeRevealContent(TypedDict):
|
|
318
|
+
source: NotRequired[ScrapeHtmlSourceEnum]
|
|
319
|
+
selector: str
|
|
320
|
+
scope: NotRequired[ScopeEnum]
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
class ScrapeRevealField(TypedDict):
|
|
324
|
+
selector: str
|
|
325
|
+
source: NotRequired[ScrapeHtmlSourceEnum]
|
|
326
|
+
attribute: NotRequired[str]
|
|
327
|
+
multiple: NotRequired[bool]
|
|
328
|
+
merge: NotRequired[MergeEnum]
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
class ScrapeRevealSelector(TypedDict):
|
|
332
|
+
source: NotRequired[ScrapeHtmlSourceEnum]
|
|
333
|
+
selector: str
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
class ScraperArtifactDownload(TypedDict):
|
|
337
|
+
url: str
|
|
338
|
+
filename: str
|
|
339
|
+
expires_in: int
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
class ScraperArtifactResponse(TypedDict):
|
|
343
|
+
id: str
|
|
344
|
+
kind: str
|
|
345
|
+
format: str
|
|
346
|
+
status: str
|
|
347
|
+
content_type: str
|
|
348
|
+
size_bytes: int
|
|
349
|
+
record_count: int | None
|
|
350
|
+
checksum: str
|
|
351
|
+
retention_until: str
|
|
352
|
+
created_at: str
|
|
353
|
+
downloadable: bool
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
class ScraperError(TypedDict):
|
|
357
|
+
code: str
|
|
358
|
+
message: str
|
|
359
|
+
retryable: bool
|
|
360
|
+
details: NotRequired[JSONValue]
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
class ScraperErrorEnvelope(TypedDict):
|
|
364
|
+
request_id: str
|
|
365
|
+
error: ScraperError
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
class ScraperHubItemResponse(TypedDict):
|
|
369
|
+
id: str
|
|
370
|
+
slug: str
|
|
371
|
+
name: str
|
|
372
|
+
description: str
|
|
373
|
+
provider: "ScraperHubProviderResponse"
|
|
374
|
+
ownership: OwnershipEnum
|
|
375
|
+
visibility: "VisibilityEnum"
|
|
376
|
+
verified: bool
|
|
377
|
+
revision: "ScraperHubRevisionResponse"
|
|
378
|
+
category: str
|
|
379
|
+
tags: list[str]
|
|
380
|
+
availability: str
|
|
381
|
+
pricing: "ScraperHubPricingResponse"
|
|
382
|
+
logo_url: str
|
|
383
|
+
input_schema: dict[str, JSONValue]
|
|
384
|
+
output_schema: dict[str, JSONValue]
|
|
385
|
+
supported_collection_modes: list[str]
|
|
386
|
+
task_ready: bool
|
|
387
|
+
updated_at: str
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
class ScraperHubPricingResponse(TypedDict):
|
|
391
|
+
type: "ScraperHubPricingResponseTypeEnum"
|
|
392
|
+
unit: NotRequired[str]
|
|
393
|
+
basis: NotRequired[str]
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
ScraperHubPricingResponseTypeEnum = Literal["free", "usage", "paid", "subscription"]
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
class ScraperHubProviderResponse(TypedDict):
|
|
400
|
+
kind: KindEnum
|
|
401
|
+
name: str
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
class ScraperHubResponse(TypedDict):
|
|
405
|
+
results: list[ScraperHubItemResponse]
|
|
406
|
+
facets: dict[str, JSONValue]
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
class ScraperHubRevisionResponse(TypedDict):
|
|
410
|
+
id: str
|
|
411
|
+
number: str
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
class ScraperHubRun(TypedDict, total=False):
|
|
415
|
+
revision: str
|
|
416
|
+
inputs: dict[str, JSONValue]
|
|
417
|
+
configuration: "ScraperHubRunConfiguration"
|
|
418
|
+
url: str
|
|
419
|
+
idempotency_key: str
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
class ScraperHubRunConfiguration(TypedDict, total=False):
|
|
423
|
+
country: str
|
|
424
|
+
locale: str
|
|
425
|
+
response_format: ResponseFormatEnum
|
|
426
|
+
render_js: bool
|
|
427
|
+
follow_redirects: bool
|
|
428
|
+
timeout_ms: int
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
class ScraperMonitorPolicyResponse(TypedDict):
|
|
432
|
+
scope: dict[str, JSONValue]
|
|
433
|
+
enabled: bool
|
|
434
|
+
window_minutes: int
|
|
435
|
+
minimum_samples: int
|
|
436
|
+
minimum_success_rate: float
|
|
437
|
+
maximum_failure_rate: float
|
|
438
|
+
maximum_p95_latency_ms: int
|
|
439
|
+
webhook_url: str
|
|
440
|
+
webhook_secret: str
|
|
441
|
+
notify_on_breach: bool
|
|
442
|
+
notify_on_recovery: bool
|
|
443
|
+
repeat_after_minutes: int
|
|
444
|
+
status: str
|
|
445
|
+
active_breaches: dict[str, JSONValue]
|
|
446
|
+
last_evaluated_at: str | None
|
|
447
|
+
recent_events: list[dict[str, JSONValue]]
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
class ScraperMonitoringResponse(TypedDict):
|
|
451
|
+
scope: dict[str, JSONValue]
|
|
452
|
+
window: str
|
|
453
|
+
window_started_at: str
|
|
454
|
+
window_ended_at: str
|
|
455
|
+
summary: dict[str, JSONValue]
|
|
456
|
+
series: list[dict[str, JSONValue]]
|
|
457
|
+
policy: ScraperMonitorPolicyResponse
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
class ScraperMonitoringScope(TypedDict):
|
|
461
|
+
type: "ScraperMonitoringScopeTypeEnum"
|
|
462
|
+
id: str
|
|
463
|
+
label: str
|
|
464
|
+
description: str
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
class ScraperMonitoringScopePage(TypedDict):
|
|
468
|
+
data: list[ScraperMonitoringScope]
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
ScraperMonitoringScopeTypeEnum = Literal["account", "scraper", "task", "schedule"]
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
class ScraperScheduleCreate(TypedDict):
|
|
475
|
+
task: NotRequired[str]
|
|
476
|
+
saved_scraper: NotRequired[str]
|
|
477
|
+
version: NotRequired[int]
|
|
478
|
+
name: str
|
|
479
|
+
enabled: NotRequired[bool]
|
|
480
|
+
frequency: RecurringScheduleFrequencyEnum
|
|
481
|
+
timezone: NotRequired[str]
|
|
482
|
+
time_of_day: str
|
|
483
|
+
weekdays: NotRequired[list[int]]
|
|
484
|
+
month_day: NotRequired[int | None]
|
|
485
|
+
overlap_policy: NotRequired[OverlapPolicyEnum]
|
|
486
|
+
inputs: NotRequired[dict[str, str]]
|
|
487
|
+
request_overrides: NotRequired["ScraperScheduleRequestOverrides"]
|
|
488
|
+
webhook_url: NotRequired[str]
|
|
489
|
+
notify_on_success: NotRequired[bool]
|
|
490
|
+
notify_on_failure: NotRequired[bool]
|
|
491
|
+
failure_threshold: NotRequired[int]
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
class ScraperScheduleRequestOverrides(TypedDict, total=False):
|
|
495
|
+
url: str
|
|
496
|
+
country: str
|
|
497
|
+
locale: str
|
|
498
|
+
response_format: ResponseFormatEnum
|
|
499
|
+
render_js: bool
|
|
500
|
+
follow_redirects: bool
|
|
501
|
+
timeout_ms: int
|
|
502
|
+
|
|
503
|
+
|
|
504
|
+
class ScraperScheduleResponse(TypedDict):
|
|
505
|
+
id: str
|
|
506
|
+
name: str
|
|
507
|
+
enabled: bool
|
|
508
|
+
health: HealthEnum
|
|
509
|
+
task: dict[str, JSONValue]
|
|
510
|
+
saved_scraper: dict[str, JSONValue]
|
|
511
|
+
frequency: str
|
|
512
|
+
timezone: str
|
|
513
|
+
time_of_day: str
|
|
514
|
+
weekdays: list[int]
|
|
515
|
+
month_day: int | None
|
|
516
|
+
overlap_policy: str
|
|
517
|
+
inputs: dict[str, JSONValue]
|
|
518
|
+
request_overrides: dict[str, JSONValue]
|
|
519
|
+
notifications: dict[str, JSONValue]
|
|
520
|
+
recent_deliveries: list[dict[str, JSONValue]]
|
|
521
|
+
next_run_at: str | None
|
|
522
|
+
last_run_at: str | None
|
|
523
|
+
last_success_at: str | None
|
|
524
|
+
consecutive_failures: int
|
|
525
|
+
total_runs: int
|
|
526
|
+
skipped_runs: int
|
|
527
|
+
last_error: JSONValue
|
|
528
|
+
recent_runs: NotRequired[list[dict[str, JSONValue]]]
|
|
529
|
+
created_at: str
|
|
530
|
+
updated_at: str
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
class ScraperStorageArtifactPage(TypedDict):
|
|
534
|
+
next: str | None
|
|
535
|
+
previous: str | None
|
|
536
|
+
results: "list[ScraperStorageArtifactResponse]"
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
class ScraperStorageArtifactResponse(TypedDict):
|
|
540
|
+
id: str
|
|
541
|
+
kind: str
|
|
542
|
+
format: str
|
|
543
|
+
status: str
|
|
544
|
+
content_type: str
|
|
545
|
+
size_bytes: int
|
|
546
|
+
record_count: int | None
|
|
547
|
+
checksum: str
|
|
548
|
+
retention_until: str
|
|
549
|
+
created_at: str
|
|
550
|
+
downloadable: bool
|
|
551
|
+
run: "ScraperStorageRun"
|
|
552
|
+
scraper: "ScraperStorageScraper | None"
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
class ScraperStorageRun(TypedDict):
|
|
556
|
+
id: str
|
|
557
|
+
status: str
|
|
558
|
+
requested_at: str
|
|
559
|
+
completed_at: str | None
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
class ScraperStorageScraper(TypedDict):
|
|
563
|
+
id: str
|
|
564
|
+
name: str
|
|
565
|
+
revision: JSONValue
|
|
566
|
+
revision_id: str
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
class ScrapingTaskConfiguration(TypedDict, total=False):
|
|
570
|
+
url: str
|
|
571
|
+
inputs: dict[str, JSONValue]
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
class ScrapingTaskCreate(TypedDict):
|
|
575
|
+
scraper: str
|
|
576
|
+
revision: NotRequired[str]
|
|
577
|
+
name: NotRequired[str]
|
|
578
|
+
description: NotRequired[str]
|
|
579
|
+
configuration: NotRequired[ScrapingTaskConfiguration]
|
|
580
|
+
|
|
581
|
+
|
|
582
|
+
class ScrapingTaskResponse(TypedDict):
|
|
583
|
+
id: str
|
|
584
|
+
name: str
|
|
585
|
+
description: str
|
|
586
|
+
source_type: "SourceTypeEnum"
|
|
587
|
+
status: str
|
|
588
|
+
current_version: int
|
|
589
|
+
version: NotRequired["ScrapingTaskVersionResponse"]
|
|
590
|
+
created_at: str
|
|
591
|
+
updated_at: str
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
class ScrapingTaskRun(TypedDict, total=False):
|
|
595
|
+
version: int
|
|
596
|
+
url: str
|
|
597
|
+
inputs: dict[str, JSONValue]
|
|
598
|
+
headers: dict[str, JSONValue]
|
|
599
|
+
body: str
|
|
600
|
+
country: str
|
|
601
|
+
locale: str
|
|
602
|
+
response_format: ResponseFormatEnum
|
|
603
|
+
render_js: bool
|
|
604
|
+
follow_redirects: bool
|
|
605
|
+
timeout_ms: int
|
|
606
|
+
idempotency_key: str
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
ScrapingTaskStatusEnum = Literal["active", "archived"]
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
class ScrapingTaskVersionCreate(TypedDict, total=False):
|
|
613
|
+
url: str
|
|
614
|
+
definition: JSONValue
|
|
615
|
+
input_schema: JSONValue
|
|
616
|
+
inputs: dict[str, JSONValue]
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
class ScrapingTaskVersionResponse(TypedDict):
|
|
620
|
+
id: str
|
|
621
|
+
version: int
|
|
622
|
+
definition: dict[str, JSONValue]
|
|
623
|
+
input_schema: dict[str, JSONValue]
|
|
624
|
+
created_at: str
|
|
625
|
+
source: NotRequired[dict[str, JSONValue]]
|
|
626
|
+
|
|
627
|
+
|
|
628
|
+
SourceTypeEnum = Literal["custom", "managed"]
|
|
629
|
+
|
|
630
|
+
VisibilityEnum = Literal["private", "shared", "unlisted", "public"]
|
|
631
|
+
|
|
632
|
+
WindowMinutesEnum = Literal[60, 360, 1440, 10080, 43200]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Typed handle for a revision-pinned public Hub scraper."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Generic, TypeVar
|
|
7
|
+
|
|
8
|
+
Inputs = TypeVar("Inputs")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class ManagedScraper(Generic[Inputs]):
|
|
13
|
+
id: str
|
|
14
|
+
revision: str
|