adspower-client 1.0.16 → 1.0.18
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/adspower-client.gemspec +2 -2
- data/lib/adspower-client.rb +46 -5
- 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: f42b0809ed76da37b7806a4f70ce727efe871def40a4a90c5810d972b0ea0556
|
4
|
+
data.tar.gz: d22f49494cae5e3ae3195984c604eea018c6dc180cb1b9dd3d62fcab55f21851
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5951622b5d9f01c5515df6ce671cd0afd6a20872e6dedab34be1d088ebef3f6811b9473a700221e7447e3e6d2d811fe149a6fa3e8cd917ae9abad84e5f8dc24
|
7
|
+
data.tar.gz: 7c589af8831eb9596ab2799ae04bd9af6433883f467234e8fe220cd04a6bfc526e31aed74d4b5671330ab5034fc207cbb54c34fc5854f1ae291b431e6985de40
|
data/adspower-client.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'adspower-client'
|
3
|
-
s.version = '1.0.
|
4
|
-
s.date = '2025-07-
|
3
|
+
s.version = '1.0.18'
|
4
|
+
s.date = '2025-07-28'
|
5
5
|
s.summary = "Ruby library for operating AdsPower API."
|
6
6
|
s.description = "Ruby library for operating AdsPower API."
|
7
7
|
s.authors = ["Leandro Daniel Sardi"]
|
data/lib/adspower-client.rb
CHANGED
@@ -104,6 +104,41 @@ class AdsPowerClient
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
end
|
107
|
+
|
108
|
+
# Fetch all groups
|
109
|
+
def list_groups
|
110
|
+
uri = URI("#{adspower_listener}:#{port}/api/v1/group/list?api_key=#{key}")
|
111
|
+
resp = Net::HTTP.get(uri)
|
112
|
+
data = JSON.parse(resp)
|
113
|
+
raise "Error listing groups: #{data['msg']}" unless data['code'] == 0
|
114
|
+
data['data']['list'] # => [{ "id" => 0, "name" => "Ungrouped" }, …]
|
115
|
+
end
|
116
|
+
|
117
|
+
# Find the numeric ID for a given group name (exact match)
|
118
|
+
def find_group_id_by_name(name)
|
119
|
+
grp = list_groups.find { |g| g['group_name'].casecmp(name).zero? }
|
120
|
+
grp ? grp['group_id'] : nil
|
121
|
+
end
|
122
|
+
|
123
|
+
# returns an Array of profile‑hashes from the local API
|
124
|
+
def list_profiles(group_id: nil)
|
125
|
+
all = []
|
126
|
+
page = 1
|
127
|
+
|
128
|
+
loop do
|
129
|
+
params = { page: page, limit: 100 }
|
130
|
+
params[:group_id] = group_id if group_id
|
131
|
+
url = "#{adspower_listener}:#{port}/api/v2/browser-profile/list"
|
132
|
+
resp = BlackStack::Netting.call_post(url, params)
|
133
|
+
data = JSON.parse(resp.body)
|
134
|
+
break unless data['code'] == 0 && data.dig('data','list').any?
|
135
|
+
batch = data['data']['list']
|
136
|
+
all += batch
|
137
|
+
page += 1
|
138
|
+
end
|
139
|
+
|
140
|
+
all
|
141
|
+
end
|
107
142
|
|
108
143
|
# Count current profiles (optionally filtered by group)
|
109
144
|
def profile_count(group_id: nil)
|
@@ -199,6 +234,7 @@ class AdsPowerClient
|
|
199
234
|
# @param proxy_config [Hash] keys: :ip, :port, :user, :password, :proxy_soft (default 'other'), :proxy_type (default 'http')
|
200
235
|
# @param group_id [String] which AdsPower group to assign (default '0')
|
201
236
|
# @param browser_version [String] optional Chrome version to use (must match Chromedriver). Only applies if `fingerprint` is nil, as custom fingerprints override kernel settings.
|
237
|
+
# @param os [String] target OS for Chrome binary (one of 'linux64', 'mac-x64', 'mac-arm64', 'win32', 'win64'; default 'linux64'); used to filter the known-good versions JSON so we pick a build that actually ships for that platform
|
202
238
|
# @param fingerprint [Hash, nil] optional fingerprint configuration. If not provided, a stealth-ready default is applied with DNS-over-HTTPS, spoofed WebGL/Canvas/audio, consistent User-Agent and locale, and hardening flags to minimize detection risks from tools like BrowserScan, Cloudflare, and Arkose Labs.
|
203
239
|
# @param platform [String] (optional) target site domain, e.g. 'linkedin.com'
|
204
240
|
# @param tabs [Array<String>] (optional) array of URLs to open on launch
|
@@ -211,7 +247,8 @@ class AdsPowerClient
|
|
211
247
|
proxy_config:,
|
212
248
|
group_id: '0',
|
213
249
|
browser_version: nil,
|
214
|
-
|
250
|
+
os: 'linux64',# new: one of linux64, mac-x64, mac-arm64, win32, win64
|
251
|
+
fingerprint: nil,
|
215
252
|
platform: '', # default: no platform
|
216
253
|
tabs: [], # default: no tabs to open
|
217
254
|
username: '', # default: no login
|
@@ -228,10 +265,14 @@ class AdsPowerClient
|
|
228
265
|
raise "Error fetching Chrome versions: HTTP #{resp.code}"
|
229
266
|
end
|
230
267
|
listing = JSON.parse(resp.body)
|
231
|
-
|
232
|
-
#
|
233
|
-
matches =
|
234
|
-
|
268
|
+
entries = listing['versions'] || []
|
269
|
+
# keep only those entries whose version matches prefix *and* has a download for our OS
|
270
|
+
matches = entries.
|
271
|
+
select { |e|
|
272
|
+
e['version'].start_with?("#{browser_version}.") &&
|
273
|
+
e.dig('downloads','chrome').any? { |d| d['platform'] == os }
|
274
|
+
}.
|
275
|
+
map { |e| e['version'] }
|
235
276
|
if matches.empty?
|
236
277
|
raise "Chrome version '#{browser_version}' not found in known-good versions list"
|
237
278
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adspower-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: uri
|