browserbeam 0.3.0 → 0.5.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 +35 -4
- data/lib/browserbeam/types.rb +12 -3
- data/lib/browserbeam/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: d16b959107bf89d7f6b0a8851b519e76548ce7968f249e1b7408d7fc9950fbc0
|
|
4
|
+
data.tar.gz: c2636291d527fe711292779e66498febc7b691701dc860a68c2826a37aa672e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b38c33925c606bd55e55c192700009efb2db1d0d86cdd561651dc43e6ad7a9aa88d2e113fcf8809b6481a40376a6abec1e4a422f46b1c1b977cd1370e7b42de
|
|
7
|
+
data.tar.gz: c1aaed1e4555eb2688ff3817bb10137f399c670316b328a0fa5f2543412513cc57dac552d439f0905d8a74ad7b9f49576bfb242713f7f9a02b685d39687d32d8
|
data/README.md
CHANGED
|
@@ -30,10 +30,17 @@ puts session.page.interactive_elements
|
|
|
30
30
|
# Interact with the page
|
|
31
31
|
session.click(ref: "e1")
|
|
32
32
|
|
|
33
|
-
# Extract
|
|
33
|
+
# Extract with CSS, AI, and JS selectors combined
|
|
34
34
|
result = session.extract(
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
products: [{
|
|
36
|
+
"_parent": ".product-card",
|
|
37
|
+
"_limit": 3,
|
|
38
|
+
"name": "h2 >> text", # CSS selector
|
|
39
|
+
"price": ".price >> text", # CSS selector
|
|
40
|
+
"url": "a >> href", # CSS attribute
|
|
41
|
+
"rating": "ai >> the star rating out of 5", # AI selector
|
|
42
|
+
"in_stock": "js >> el.querySelector('.stock')?.textContent.includes('In stock')", # JS
|
|
43
|
+
}]
|
|
37
44
|
)
|
|
38
45
|
puts result.extraction
|
|
39
46
|
|
|
@@ -57,15 +64,33 @@ client = Browserbeam::Client.new(
|
|
|
57
64
|
session = client.sessions.create(
|
|
58
65
|
url: "https://example.com",
|
|
59
66
|
viewport: { width: 1280, height: 720 },
|
|
67
|
+
user_agent: "Mozilla/5.0 ...", # omit for automatic rotation
|
|
60
68
|
locale: "en-US",
|
|
61
69
|
timezone: "America/New_York",
|
|
62
|
-
proxy: "http://user:pass@proxy:8080",
|
|
63
70
|
block_resources: ["image", "font"],
|
|
64
71
|
auto_dismiss_blockers: true,
|
|
65
72
|
timeout: 300,
|
|
66
73
|
)
|
|
67
74
|
```
|
|
68
75
|
|
|
76
|
+
### Proxies
|
|
77
|
+
|
|
78
|
+
All sessions use a datacenter proxy by default (country auto-detected from the URL's TLD). No configuration needed. To customize:
|
|
79
|
+
|
|
80
|
+
```ruby
|
|
81
|
+
# Use a residential proxy for a specific country
|
|
82
|
+
session = client.sessions.create(
|
|
83
|
+
url: "https://example.com",
|
|
84
|
+
proxy: { kind: "residential", country: "us" },
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Or bring your own proxy (overrides managed proxy)
|
|
88
|
+
session = client.sessions.create(
|
|
89
|
+
url: "https://example.com",
|
|
90
|
+
proxy: "http://user:pass@proxy:8080",
|
|
91
|
+
)
|
|
92
|
+
```
|
|
93
|
+
|
|
69
94
|
## Available Methods
|
|
70
95
|
|
|
71
96
|
| Method | Description |
|
|
@@ -120,9 +145,15 @@ puts full.page.markdown.content
|
|
|
120
145
|
|
|
121
146
|
## Session Management
|
|
122
147
|
|
|
148
|
+
Filter by `status: "active"`, `"closed"`, or `"failed"`. Failed sessions ended with a fatal error (e.g. blocked or unsolvable challenge); `get` returns `error_code` and `error_message`.
|
|
149
|
+
|
|
123
150
|
```ruby
|
|
124
151
|
sessions = client.sessions.list(status: "active")
|
|
152
|
+
failed = client.sessions.list(status: "failed")
|
|
125
153
|
info = client.sessions.get("ses_abc123")
|
|
154
|
+
if info.status == "failed"
|
|
155
|
+
warn "#{info.error_code}: #{info.error_message}"
|
|
156
|
+
end
|
|
126
157
|
client.sessions.destroy("ses_abc123")
|
|
127
158
|
```
|
|
128
159
|
|
data/lib/browserbeam/types.rb
CHANGED
|
@@ -95,7 +95,9 @@ module Browserbeam
|
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
-
SessionInfo = Struct.new(
|
|
98
|
+
SessionInfo = Struct.new(
|
|
99
|
+
:session_id, :status, :started_at, :ended_at, :duration_seconds, :expires_at, :error_code, :error_message, keyword_init: true
|
|
100
|
+
) do
|
|
99
101
|
def self.from_hash(data)
|
|
100
102
|
new(
|
|
101
103
|
session_id: data["session_id"] || "",
|
|
@@ -104,13 +106,20 @@ module Browserbeam
|
|
|
104
106
|
ended_at: data["ended_at"],
|
|
105
107
|
duration_seconds: data["duration_seconds"],
|
|
106
108
|
expires_at: data["expires_at"] || "",
|
|
109
|
+
error_code: data["error_code"],
|
|
110
|
+
error_message: data["error_message"]
|
|
107
111
|
)
|
|
108
112
|
end
|
|
109
113
|
end
|
|
110
114
|
|
|
111
|
-
SessionListItem = Struct.new(:session_id, :status, :started_at, keyword_init: true) do
|
|
115
|
+
SessionListItem = Struct.new(:session_id, :status, :started_at, :error_code, keyword_init: true) do
|
|
112
116
|
def self.from_hash(data)
|
|
113
|
-
new(
|
|
117
|
+
new(
|
|
118
|
+
session_id: data["session_id"] || "",
|
|
119
|
+
status: data["status"] || "",
|
|
120
|
+
started_at: data["started_at"] || "",
|
|
121
|
+
error_code: data["error_code"]
|
|
122
|
+
)
|
|
114
123
|
end
|
|
115
124
|
end
|
|
116
125
|
|
data/lib/browserbeam/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: browserbeam
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Browserbeam
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|