hydrafetch 0.2.0 → 0.4.1
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 +38 -1
- data/lib/hydrafetch/client.rb +23 -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: f5a61cb3f085942a425d49d332d90facc8f698128393e6857fe9f9b50a200f35
|
|
4
|
+
data.tar.gz: 1332a661781e5859b3a2783c64b7fced6154e64222a189073d5f28be7601ccbc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24a54e965440320001b8c4cdc9708a8a913b00ed59b3cc0de04a008920ad1a659910601d720788ce0e9bd67019b205c28ecdeb172f9fb7b35b15ec5410a48f77
|
|
7
|
+
data.tar.gz: e18d9fb8acfcffc52f24c16f69be82c1293fb2e704c0342a442560e5955d40e788433beb6efaeb4ca103db357c5958e1ed919388c30444a9a3bc3f5a4ca8a6a3
|
data/README.md
CHANGED
|
@@ -31,7 +31,7 @@ page = hf.scrape("https://example.com/article")
|
|
|
31
31
|
puts page["markdown"]
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Copy your key from [app.hydrafetch.com](https://app.hydrafetch.com). The constructor reads `HYDRAFETCH_API_KEY` when no key is passed.
|
|
35
35
|
|
|
36
36
|
Responses are plain hashes with string keys. Option names are camelCase because they are passed to the API unchanged; client options such as `poll_interval:` and `job_timeout:` are snake_case.
|
|
37
37
|
|
|
@@ -120,6 +120,24 @@ res["results"].each do |r|
|
|
|
120
120
|
end
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
+
## Jobs
|
|
124
|
+
|
|
125
|
+
Search open jobs collected from company career sites and hiring platforms, by the words in the job title:
|
|
126
|
+
|
|
127
|
+
```ruby
|
|
128
|
+
jobs = hf.search_jobs("data engineer", location: "Berlin", postedWithinDays: 14, limit: 20)
|
|
129
|
+
jobs.each { |job| puts "#{job["title"]} #{job["domain"]} #{job["url"]}" }
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
See what changed in a company's hiring since a date: what is open now, what opened and what closed, by department, seniority and location, with the jobs themselves:
|
|
133
|
+
|
|
134
|
+
```ruby
|
|
135
|
+
acme = hf.hiring_changes("acme.com", "2026-10-01").first
|
|
136
|
+
puts acme["totals"] # {"open"=>42, "opened"=>6, "closed"=>3}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
A search costs 1 credit per 10 jobs returned, and an empty one is free. Hiring changes cost 1 credit per company we have jobs for; companies we do not track yet come back empty and are free.
|
|
140
|
+
|
|
123
141
|
## Brand data
|
|
124
142
|
|
|
125
143
|
```ruby
|
|
@@ -131,6 +149,22 @@ hf.styleguide("https://stripe.com/pricing", maxAge: 0) # one page, read fresh
|
|
|
131
149
|
|
|
132
150
|
For logos in a browser use [`@hydrafetch/client-sdk`](https://github.com/Hydrafetch/client-sdk) with a publishable key. Those bill against logo pulls rather than credits.
|
|
133
151
|
|
|
152
|
+
## Rating results
|
|
153
|
+
|
|
154
|
+
Tell us when a result was wrong, so it gets looked at. It is free, and rating the same request again replaces the earlier rating.
|
|
155
|
+
|
|
156
|
+
```ruby
|
|
157
|
+
hf.scrape("https://stripe.com/pricing")
|
|
158
|
+
hf.rate_result("bad",
|
|
159
|
+
request_id: hf.last_request_id,
|
|
160
|
+
reasons: ["missing_content"],
|
|
161
|
+
note: "The enterprise tier is missing")
|
|
162
|
+
|
|
163
|
+
hf.rate_result("good", url: "https://stripe.com/pricing") # by URL, last 24 hours
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Reasons are `missing_content`, `wrong_content`, `blocked`, `slow`, `formatting` and `other`.
|
|
167
|
+
|
|
134
168
|
## Error handling
|
|
135
169
|
|
|
136
170
|
All failures raise `Hydrafetch::Error`, carrying the API's error code, HTTP status and request id.
|
|
@@ -179,6 +213,8 @@ hf = Hydrafetch::Client.new("hf_...",
|
|
|
179
213
|
| `markdown(url, **options)` | `String` | 1 |
|
|
180
214
|
| `map(url, **options)` | links hash | 1 |
|
|
181
215
|
| `search(query, **options)` | results hash | 1 + 1 per scraped result |
|
|
216
|
+
| `search_jobs(query, **options)` | array of jobs | 1 per 10 jobs |
|
|
217
|
+
| `hiring_changes(domains, since, **options)` | array of companies | 1 per company with jobs |
|
|
182
218
|
| `extract(urls, **options)` | hash with `"results"` | 5 per URL |
|
|
183
219
|
| `brand(domain)` | brand hash | 5 |
|
|
184
220
|
| `logo(domain, **options)` | logo hash | 1 |
|
|
@@ -189,6 +225,7 @@ hf = Hydrafetch::Client.new("hf_...",
|
|
|
189
225
|
| `batch(urls, **options)` | job hash, polled to completion | 1 per page |
|
|
190
226
|
| `start_crawl`, `start_batch` | job id `String` | 1 per page |
|
|
191
227
|
| `crawl_status(id)`, `batch_status(id)` | job hash | free |
|
|
228
|
+
| `rate_result(rating, request_id:, url:, reasons:, note:)` | rating hash | free |
|
|
192
229
|
|
|
193
230
|
Failed requests are not billed. Pricing does not vary with page difficulty, so there is no render, stealth or proxy option to set.
|
|
194
231
|
|
data/lib/hydrafetch/client.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
require "net/http"
|
|
3
|
+
require "time"
|
|
3
4
|
require "uri"
|
|
4
5
|
|
|
5
6
|
require_relative "errors"
|
|
@@ -11,7 +12,7 @@ module Hydrafetch
|
|
|
11
12
|
DEFAULT_MAX_RETRIES = 2
|
|
12
13
|
TERMINAL_STATUSES = %w[completed failed cancelled].freeze
|
|
13
14
|
|
|
14
|
-
attr_reader :base_url
|
|
15
|
+
attr_reader :base_url, :last_request_id
|
|
15
16
|
|
|
16
17
|
def initialize(api_key = nil, base_url: DEFAULT_BASE_URL, timeout: DEFAULT_TIMEOUT,
|
|
17
18
|
max_retries: DEFAULT_MAX_RETRIES)
|
|
@@ -32,6 +33,16 @@ module Hydrafetch
|
|
|
32
33
|
post("/v1/web/scrape", { url: url }.merge(compact(options)))
|
|
33
34
|
end
|
|
34
35
|
|
|
36
|
+
def rate_result(rating, request_id: nil, url: nil, reasons: nil, note: nil)
|
|
37
|
+
if request_id.nil? && url.nil?
|
|
38
|
+
raise Error.new("Pass request_id: or url: to say which result you are rating.",
|
|
39
|
+
code: "VALIDATION_ERROR", status: 400)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
post("/v1/web/feedback", compact(requestId: request_id, url: url, rating: rating,
|
|
43
|
+
reasons: reasons, note: note))
|
|
44
|
+
end
|
|
45
|
+
|
|
35
46
|
def markdown(url, **options)
|
|
36
47
|
scrape(url, formats: ["markdown"], **options)["markdown"]
|
|
37
48
|
end
|
|
@@ -44,6 +55,16 @@ module Hydrafetch
|
|
|
44
55
|
post("/v1/web/search", { query: query }.merge(compact(options)))
|
|
45
56
|
end
|
|
46
57
|
|
|
58
|
+
def search_jobs(query, **options)
|
|
59
|
+
post("/v1/web/index/jobs/search", { query: query }.merge(compact(options)))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def hiring_changes(domains, since, **options)
|
|
63
|
+
list = domains.is_a?(String) ? [domains] : domains.to_a
|
|
64
|
+
at = since.respond_to?(:iso8601) ? since.iso8601 : since
|
|
65
|
+
post("/v1/web/index/jobs/changes", { domains: list, since: at }.merge(compact(options)))
|
|
66
|
+
end
|
|
67
|
+
|
|
47
68
|
def extract(urls, **options)
|
|
48
69
|
list = urls.is_a?(String) ? [urls] : urls.to_a
|
|
49
70
|
post("/v1/web/extract", { urls: list }.merge(compact(options)))
|
|
@@ -162,6 +183,7 @@ module Hydrafetch
|
|
|
162
183
|
end
|
|
163
184
|
|
|
164
185
|
res = http_for(uri).request(req)
|
|
186
|
+
@last_request_id = res["x-request-id"] || @last_request_id
|
|
165
187
|
unwrap(res)
|
|
166
188
|
rescue Error => e
|
|
167
189
|
raise unless e.retryable? && attempt < @max_retries
|
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.4.1
|
|
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
|
+
date: 2026-11-04 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.
|