hydrafetch 0.7.0 → 0.9.0
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.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/hydrafetch/client.rb +11 -0
- data/lib/hydrafetch/errors.rb +1 -1
- data/lib/hydrafetch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6803400e320cc7ed542631cc9f631247e3c6c93efd911f3721a60ca466e1c3c6
|
|
4
|
+
data.tar.gz: 9329e00975fa14f4ce43233ccc3d2ede82e2c90ca3b5e72794a9fd5e8da2ed05
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 93a37b14a57b9264caf694f8a4a1b93707550d98aefab55b0fc4bac96b90ce73b7e4931dc5a500ec4213d2621871d9b8232d933cc8cdc04969a8a70e909e5d97
|
|
7
|
+
data.tar.gz: af6713c7bbb3e611f02351a6a48c0577f71beaae03e8b0ffac3a123399b53ff47c8860a981e242df9874529c05fa344f7466b94ad603ebd6e7a5ce432a7bb0ae
|
data/README.md
CHANGED
|
@@ -205,7 +205,7 @@ end
|
|
|
205
205
|
| 429 | rate limited | yes, twice |
|
|
206
206
|
| 5xx | upstream failure | yes, twice |
|
|
207
207
|
|
|
208
|
-
Retries wait as long as the response asks through `Retry-After` or `retryAfterSeconds`, and otherwise back off with jitter. When the response asks for more than 30 seconds the client does not wait; it raises at once and `e.retry_after` gives the seconds to wait before asking again. A dropped connection is retried too, including while the client follows a job, and a job that fails is never started a second time.
|
|
208
|
+
Retries wait as long as the response asks through `Retry-After` or `retryAfterSeconds`, and otherwise back off with jitter. When the response asks for more than 30 seconds the client does not wait; it raises at once and `e.retry_after` gives the seconds to wait before asking again. A dropped connection is retried too, including while the client follows a job, and a job that fails is never started a second time. Every POST carries an Idempotency-Key that its own retries reuse, so a retry after a dropped connection returns the first answer instead of running and charging again.
|
|
209
209
|
|
|
210
210
|
A 503 from `scrape` means the origin is unreachable, usually a dead domain or a broken certificate.
|
|
211
211
|
|
|
@@ -239,6 +239,7 @@ hf = Hydrafetch::Client.new("hf_...",
|
|
|
239
239
|
| `batch(urls, **options)` | job hash, polled to completion | 1 per page |
|
|
240
240
|
| `start_crawl`, `start_batch` | job id `String` | 1 per page |
|
|
241
241
|
| `crawl_status(id)`, `batch_status(id)` | job hash | free |
|
|
242
|
+
| `cancel_crawl(id)`, `cancel_batch(id)` | job hash | free, pages not yet read are not charged |
|
|
242
243
|
| `rate_result(rating, request_id:, url:, reasons:, note:)` | rating hash | free |
|
|
243
244
|
|
|
244
245
|
Failed requests are not billed. Pricing does not vary with page difficulty, so there is no render, stealth or proxy option to set.
|
data/lib/hydrafetch/client.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "json"
|
|
2
|
+
require "securerandom"
|
|
2
3
|
require "net/http"
|
|
3
4
|
require "time"
|
|
4
5
|
require "uri"
|
|
@@ -123,6 +124,14 @@ module Hydrafetch
|
|
|
123
124
|
get("/v1/web/batch/#{escape(id)}")
|
|
124
125
|
end
|
|
125
126
|
|
|
127
|
+
def cancel_crawl(id)
|
|
128
|
+
request(Net::HTTP::Delete, "/v1/web/crawl/#{escape(id)}")
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def cancel_batch(id)
|
|
132
|
+
request(Net::HTTP::Delete, "/v1/web/batch/#{escape(id)}")
|
|
133
|
+
end
|
|
134
|
+
|
|
126
135
|
def crawl(url, poll_interval: 2, job_timeout: 300, on_progress: nil, **options)
|
|
127
136
|
id = start_crawl(url, **options)
|
|
128
137
|
wait(poll_interval, job_timeout, on_progress) { crawl_status(id) }
|
|
@@ -185,10 +194,12 @@ module Hydrafetch
|
|
|
185
194
|
uri.query = URI.encode_www_form(query) unless query.nil? || query.empty?
|
|
186
195
|
|
|
187
196
|
attempt = 0
|
|
197
|
+
idempotency_key = verb == Net::HTTP::Post ? SecureRandom.uuid : nil
|
|
188
198
|
begin
|
|
189
199
|
req = verb.new(uri)
|
|
190
200
|
req["X-API-Key"] = @api_key
|
|
191
201
|
req["Accept"] = "application/json"
|
|
202
|
+
req["Idempotency-Key"] = idempotency_key if idempotency_key
|
|
192
203
|
if body
|
|
193
204
|
req["Content-Type"] = "application/json"
|
|
194
205
|
req.body = JSON.generate(body)
|
data/lib/hydrafetch/errors.rb
CHANGED
data/lib/hydrafetch/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hydrafetch
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hydrafetch
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Turn any URL into clean Markdown and structured data. Scrape, map, search,
|
|
14
14
|
extract, brand and bulk crawl through one API.
|