ethon-impersonate 0.17.10-x86_64-darwin-24

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.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +391 -0
  3. data/LICENSE +21 -0
  4. data/README.md +164 -0
  5. data/config/puma.rb +1 -0
  6. data/ethon-impersonate.gemspec +29 -0
  7. data/ext/libcurl-impersonate.4.dylib +0 -0
  8. data/lib/ethon-impersonate.rb +1 -0
  9. data/lib/ethon_impersonate/curl.rb +90 -0
  10. data/lib/ethon_impersonate/curls/classes.rb +65 -0
  11. data/lib/ethon_impersonate/curls/codes.rb +122 -0
  12. data/lib/ethon_impersonate/curls/constants.rb +81 -0
  13. data/lib/ethon_impersonate/curls/form_options.rb +37 -0
  14. data/lib/ethon_impersonate/curls/functions.rb +59 -0
  15. data/lib/ethon_impersonate/curls/infos.rb +151 -0
  16. data/lib/ethon_impersonate/curls/messages.rb +19 -0
  17. data/lib/ethon_impersonate/curls/options.rb +503 -0
  18. data/lib/ethon_impersonate/curls/settings.rb +13 -0
  19. data/lib/ethon_impersonate/easy/callbacks.rb +149 -0
  20. data/lib/ethon_impersonate/easy/debug_info.rb +49 -0
  21. data/lib/ethon_impersonate/easy/features.rb +31 -0
  22. data/lib/ethon_impersonate/easy/form.rb +107 -0
  23. data/lib/ethon_impersonate/easy/header.rb +65 -0
  24. data/lib/ethon_impersonate/easy/http/actionable.rb +157 -0
  25. data/lib/ethon_impersonate/easy/http/custom.rb +29 -0
  26. data/lib/ethon_impersonate/easy/http/delete.rb +25 -0
  27. data/lib/ethon_impersonate/easy/http/get.rb +24 -0
  28. data/lib/ethon_impersonate/easy/http/head.rb +24 -0
  29. data/lib/ethon_impersonate/easy/http/options.rb +24 -0
  30. data/lib/ethon_impersonate/easy/http/patch.rb +24 -0
  31. data/lib/ethon_impersonate/easy/http/post.rb +26 -0
  32. data/lib/ethon_impersonate/easy/http/postable.rb +32 -0
  33. data/lib/ethon_impersonate/easy/http/put.rb +27 -0
  34. data/lib/ethon_impersonate/easy/http/putable.rb +25 -0
  35. data/lib/ethon_impersonate/easy/http.rb +68 -0
  36. data/lib/ethon_impersonate/easy/informations.rb +118 -0
  37. data/lib/ethon_impersonate/easy/mirror.rb +38 -0
  38. data/lib/ethon_impersonate/easy/operations.rb +64 -0
  39. data/lib/ethon_impersonate/easy/options.rb +50 -0
  40. data/lib/ethon_impersonate/easy/params.rb +29 -0
  41. data/lib/ethon_impersonate/easy/queryable.rb +154 -0
  42. data/lib/ethon_impersonate/easy/response_callbacks.rb +136 -0
  43. data/lib/ethon_impersonate/easy/util.rb +28 -0
  44. data/lib/ethon_impersonate/easy.rb +332 -0
  45. data/lib/ethon_impersonate/errors/ethon_error.rb +9 -0
  46. data/lib/ethon_impersonate/errors/global_init.rb +13 -0
  47. data/lib/ethon_impersonate/errors/invalid_option.rb +13 -0
  48. data/lib/ethon_impersonate/errors/invalid_value.rb +13 -0
  49. data/lib/ethon_impersonate/errors/multi_add.rb +12 -0
  50. data/lib/ethon_impersonate/errors/multi_fdset.rb +12 -0
  51. data/lib/ethon_impersonate/errors/multi_remove.rb +12 -0
  52. data/lib/ethon_impersonate/errors/multi_timeout.rb +13 -0
  53. data/lib/ethon_impersonate/errors/select.rb +13 -0
  54. data/lib/ethon_impersonate/errors.rb +17 -0
  55. data/lib/ethon_impersonate/impersonate/fingerprints.rb +16 -0
  56. data/lib/ethon_impersonate/impersonate/settings.rb +86 -0
  57. data/lib/ethon_impersonate/impersonate/targets.rb +99 -0
  58. data/lib/ethon_impersonate/impersonate/tls.rb +189 -0
  59. data/lib/ethon_impersonate/impersonate.rb +10 -0
  60. data/lib/ethon_impersonate/libc.rb +21 -0
  61. data/lib/ethon_impersonate/loggable.rb +59 -0
  62. data/lib/ethon_impersonate/multi/operations.rb +228 -0
  63. data/lib/ethon_impersonate/multi/options.rb +117 -0
  64. data/lib/ethon_impersonate/multi/stack.rb +49 -0
  65. data/lib/ethon_impersonate/multi.rb +126 -0
  66. data/lib/ethon_impersonate/version.rb +6 -0
  67. data/lib/ethon_impersonate.rb +28 -0
  68. metadata +122 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 15ec8cad2bc555434a7852ad25547c1d9f8c4e2940c41811790777e22044a6c3
4
+ data.tar.gz: 20aa79252a2079229df35d19a0bef0e819a29c398779b5dd832851f508399efb
5
+ SHA512:
6
+ metadata.gz: 48219405d85223625bf14c6e51caa7a85b7a97c44b2c06e1a0c6c698b25d17378f6171fd3d6836de264e2face266daabe5c8044e28c7526d8ce73f2b8300cd7a
7
+ data.tar.gz: 9959463e6060e87857218e01767db283f6d348728a22f2d3f997c4208fe479673960b8b0f1cf106d04bee0da25819e0d23eaa9e8751a7fbd422196835035fa3e
data/CHANGELOG.md ADDED
@@ -0,0 +1,391 @@
1
+ # Changelog
2
+
3
+ ## Master
4
+
5
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.17.9...master)
6
+
7
+ ## 0.17.9
8
+
9
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.17.8...v0.17.9)
10
+
11
+ * Bumped [`curl-impersonate`](https://github.com/lexiforest/curl-impersonate) to `v1.0.0`
12
+
13
+ ## 0.17.8
14
+
15
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.16.0...v0.17.8)
16
+
17
+ * Added basic support for [`curl-impersonate`](https://github.com/lexiforest/curl-impersonate) @ `v1.0.0rc1`
18
+
19
+ ## 0.16.0
20
+
21
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.15.0...v0.16.0)
22
+
23
+ * Added `redirect_url` value to available informations and `Easy::Mirror`.
24
+ ([Adrien Rey-Jarthon](https://github.com/jarthod)
25
+
26
+ ## 0.15.0
27
+
28
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.14.0...v0.15.0)
29
+
30
+ ## 0.12.0
31
+
32
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.11.0...v0.12.0)
33
+
34
+ - Removed deprecated `CURLE_SSL_CACERT` pinned in curl v7.62.0 ([@arku](https://github.com/arku) in [#158](https://github.com/serpapi/ethon-impersonate/pull/158))
35
+
36
+
37
+ ## 0.11.0
38
+
39
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.10.1...v0.11.0)
40
+
41
+ ## 0.10.1
42
+
43
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.10.0...v0.10.1)
44
+
45
+ ## 0.10.0
46
+
47
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.9.1...v0.10.0)
48
+
49
+ ## 0.9.1
50
+
51
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.9.0...v0.9.1)
52
+
53
+ ## 0.9.0
54
+
55
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.8.1...v0.9.0)
56
+
57
+ ## 0.8.1
58
+
59
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.8.0...v0.8.1)
60
+
61
+ * Support optional escaping of params.
62
+ ([Tasos Laskos](https://github.com/zapotek)
63
+ * `Easy::Mirror`: Reduced object allocations and method calls during info handling.
64
+ ([Tasos Laskos](https://github.com/zapotek)
65
+
66
+ ## 0.8.0
67
+
68
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.7.3...v0.7.4)
69
+
70
+ * `Easy::Mirror`: Reduced object allocations and method calls during info handling.
71
+ ([Tasos Laskos](https://github.com/zapotek)
72
+
73
+ ## 0.7.4
74
+
75
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.7.3...v0.7.4)
76
+
77
+ * Support different array encodings for params.
78
+ ([Marcello Barnaba](https://github.com/ifad), [\#104](https://github.com/serpapi/ethon-impersonate/pull/104))
79
+ * Programtic access to version infos.
80
+ ([Jonas Wagner](https://github.com/jwagner), [\#90](https://github.com/serpapi/ethon-impersonate/pull/90))
81
+
82
+
83
+ ## 0.7.3
84
+
85
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.7.2...v0.7.3)
86
+
87
+ * `EthonImpersonate::Curl::FDSet`
88
+ * Set `:fd_array` size to the current MS Windows `FD_SETSIZE` (2048).
89
+ ([Tasos Laskos](https://github.com/zapotek)
90
+
91
+ * Added `redirect_time` value to available informations and `Easy::Mirror`.
92
+ ([Adrien Jarthon](https://github.com/jarthod)
93
+
94
+ ## 0.7.2
95
+
96
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.7.1...v0.7.2)
97
+
98
+ * FFI data-types updated to be more correct.
99
+
100
+ ## 0.7.1
101
+
102
+ * MS Windows determination delegated to `Gem.windows?` for better accuracy.
103
+ * FFI data-types updated to work on MS Windows.
104
+
105
+ ## 0.7.0
106
+
107
+ Not backwards compatible changes:
108
+
109
+ * `mime-types` are no longer a dependency. The gem will be still used if available to determine the mime type of a file which is uploaded. That means you have to have take care of the gem installation yourself.
110
+
111
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.6.3...v0.7.0)
112
+
113
+ ## 0.6.3
114
+
115
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.6.2...v0.6.3)
116
+
117
+ ## 0.6.2
118
+
119
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.6.1...v0.6.2)
120
+
121
+ ## 0.6.1
122
+
123
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.6.0...v0.6.1)
124
+
125
+ The changelog entries are coming soon!
126
+
127
+ ## 0.6.0
128
+
129
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.12...v0.6.0)
130
+
131
+ The changelog entries are coming soon!
132
+
133
+ Bugfixes:
134
+
135
+ * URL-encode nullbytes in parameters instead of escaping them to `\\0`.
136
+ ([Tasos Laskos](https://github.com/zapotek)
137
+
138
+ ## 0.5.12
139
+
140
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.11...v0.5.12)
141
+
142
+ Enhancements:
143
+
144
+ * Performance optimizations.
145
+ ([Kyle Oppenheim](https://github.com/koppenheim) and [Richie Vos](https://github.com/richievos), [\#48](https://github.com/serpapi/ethon-impersonate/pull/48))
146
+ * Reuse memory pointer.
147
+ ([Richie Vos](https://github.com/richievos), [\#49](https://github.com/serpapi/ethon-impersonate/pull/49))
148
+
149
+ Bugfixes:
150
+
151
+ * Fix windows install.
152
+ ([Derik Olsson](https://github.com/derikolsson), [\#47](https://github.com/serpapi/ethon-impersonate/pull/47))
153
+ * Handle urls that already contain query params.
154
+ ([Turner King](https://github.com/turnerking ), [\#45](https://github.com/serpapi/ethon-impersonate/pull/45))
155
+
156
+ ## 0.5.11
157
+
158
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.10...v0.5.11)
159
+
160
+ Enhancements:
161
+
162
+ * Add support for postredirs, unrestricted_auth.
163
+ * Add support for cookie, cookiejar, cookiefile.
164
+ ([erwanlr](https://github.com/erwanlr), [\#46](https://github.com/serpapi/ethon-impersonate/pull/46))
165
+ * Relax ffi requirements.
166
+ ([voxik](https://github.com/voxik), [\#40](https://github.com/serpapi/ethon-impersonate/pull/40))
167
+ * Various documentation improvements.
168
+ ([Craig Little](https://github.com/craiglittle))
169
+
170
+ Bugfixes:
171
+
172
+ * Fix the memory leaks.
173
+ ([Richie Vos](https://github.com/richievos), [\#45](https://github.com/serpapi/ethon-impersonate/pull/45))
174
+
175
+ ## 0.5.10
176
+
177
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.9...v0.5.10)
178
+
179
+ Enhancements:
180
+
181
+ * Allow custom requests.
182
+ ([Nathan Sutton](https://github.com/nate), [\#36](https://github.com/serpapi/ethon-impersonate/pull/36))
183
+ * Use updated version of FFI.
184
+
185
+ Bugfixes:
186
+
187
+ * Fix windows install issue.
188
+ ([brainsucker](https://github.com/brainsucker), [\#38](https://github.com/serpapi/ethon-impersonate/pull/38))
189
+
190
+ ## 0.5.9
191
+
192
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.8...v0.5.9)
193
+
194
+ Enhancements:
195
+
196
+ * Allow to set multiple protocols.
197
+
198
+ ## 0.5.8
199
+
200
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.7...v0.5.8)
201
+
202
+ Enhancements:
203
+
204
+ * Add support for protocols and redir_protocols(
205
+ [libcurl SASL buffer overflow vulnerability](http://curl.haxx.se/docs/adv_20130206.html)).
206
+ * Add max_send_speed_large and max_recv_speed_large([Paul Schuegraf](https://github.com/pschuegr), [\#33](https://github.com/serpapi/ethon-impersonate/pull/33))
207
+
208
+ ## 0.5.7
209
+
210
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.6...v0.5.7)
211
+
212
+ Enhancements:
213
+
214
+ * Use new version of ffi.
215
+
216
+ ## 0.5.6
217
+
218
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.4...v0.5.6)
219
+
220
+ Bugfixes:
221
+
222
+ * Easy#reset resets on_complete callbacks.
223
+
224
+ ## 0.5.4
225
+
226
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.3...v0.5.4)
227
+
228
+ Enhancements:
229
+
230
+ * Use Libc#getdtablesize to get the FDSet size.
231
+ * New libcurl option accept_encoding.
232
+ * Documentation updates.
233
+
234
+ ## 0.5.3
235
+
236
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.2...v0.5.3)
237
+
238
+ Enhancements:
239
+
240
+ * Deprecate Easy#prepare. It is no longer necessary.
241
+ * Unroll metaprogramming for easy and multi options.
242
+ * More specs.
243
+
244
+ Bugfixes:
245
+
246
+ * Correct size for FDSets
247
+ * Add proxytypes to enums.
248
+
249
+ ## 0.5.2
250
+
251
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.1...v0.5.2)
252
+
253
+ Enhancements:
254
+
255
+ * New libcurl option keypasswd.
256
+
257
+ Bugfixes:
258
+
259
+ * Correct request logging when using multi interface.
260
+ * Remove invalid libcurl option sslcertpasswd.
261
+
262
+ ## 0.5.1
263
+
264
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.5.0...v0.5.1)
265
+
266
+ Bugfixes:
267
+
268
+ * Mark Curl.select and Curl.easy_perform as blocking so that the GIL is
269
+ released by ffi.
270
+
271
+ ## 0.5.0
272
+
273
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.4.4...v0.5.0)
274
+
275
+ Enhancements:
276
+
277
+ * New libcurl option proxyuserpwd
278
+ * Rename response_header to response_headers
279
+
280
+ Bugfixes:
281
+
282
+ * Mark Curl.select and Curl.easy_perform as blocking so that the GIL is
283
+ released by ffi.
284
+
285
+ ## 0.4.4
286
+
287
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.4.3...v0.4.4)
288
+
289
+ Enhancements:
290
+
291
+ * Prepare multi explicit like easy
292
+
293
+ ## 0.4.3
294
+
295
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.4.2...v0.4.3)
296
+
297
+ Enhancements:
298
+
299
+ * Remove deprecated libcurl option put
300
+ * More documentation
301
+ * New libcurl option connecttimeout_ms and timeout_ms
302
+ * Support multi options
303
+
304
+ Bugfixes:
305
+
306
+ * Handle nil values in query params
307
+
308
+ ## 0.4.2
309
+
310
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.4.1...v0.4.2)
311
+
312
+ Enhancements:
313
+
314
+ * New libcurl option forbid_reuse
315
+ * Use libcurls escape instead of CGI::escape
316
+
317
+ ## 0.4.1
318
+
319
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.4.0...v0.4.1)
320
+
321
+ Bugfixes:
322
+
323
+ * Handle nested hash in an array in params correct
324
+ ( [\#201](https://github.com/typhoeus/typhoeus/issues/201) )
325
+
326
+ ## 0.4.0
327
+
328
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.3.0...v0.4.0)
329
+
330
+ Enhancements:
331
+
332
+ * ruby 1.8.7 compatible
333
+ * EthonImpersonate.logger
334
+ * Deal with string param/body
335
+ * More documentation
336
+
337
+ Bugfixes:
338
+
339
+ * Add multi_cleanup to curl
340
+
341
+ ## 0.3.0
342
+
343
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.2.0...v0.3.0)
344
+
345
+ Enhancements:
346
+
347
+ * New libcurl option proxyport
348
+ * Raise invalid value error when providing a wrong key for sslversion or httpauth
349
+
350
+ Bugfixes:
351
+
352
+ * Libcurl option sslversion is handled correct
353
+
354
+ ## 0.2.0
355
+
356
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.1.0...v0.2.0)
357
+
358
+ Enhancements:
359
+
360
+ * GET requests are using custom requests only when there is a request body
361
+ * Easy#on_complete takes multiple callbacks
362
+ * raise Errors::GlobalInit when libcurls global_init failed instead of
363
+ runtime error
364
+ * raise Errors::InvalidOption if option is invalid
365
+
366
+ ## 0.1.0
367
+
368
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.0.2...v0.1.0)
369
+
370
+ Enhancements:
371
+
372
+ * Documentation
373
+ ( [Alex P](https://github.com/ifesdjeen), [\#13](https://github.com/typhoeus/ethon/issues/13) )
374
+ * New libcurl option dns_cache_timeout
375
+ ( [Chris Heald](https://github.com/cheald), [\#192](https://github.com/typhoeus/typhoeus/pull/192) )
376
+
377
+ Bugfixes:
378
+
379
+ * Libcurl option ssl_verifyhost takes an integer.
380
+ * Add space between header key and value.
381
+
382
+ ## 0.0.2
383
+
384
+ [Full Changelog](https://github.com/serpapi/ethon-impersonate/compare/v0.0.1...v0.0.2)
385
+
386
+ Bugfixes:
387
+
388
+ * Add libcurl.so.4 to ffi_lib in order to load correct lib on Debian.
389
+ * Escape zero bytes.
390
+
391
+ ## 0.0.1 Initial version
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2025 SerpApi
2
+ Copyright (c) 2012-2016 Hans Hasselberg
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,164 @@
1
+
2
+
3
+ # Ethon Impersonate ![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_24x24.png "Chrome") ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_24x24.png "Edge") ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_24x24.png "Safari") ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png "Firefox") ![Tor](https://raw.githubusercontent.com/alrra/browser-logos/main/src/tor/tor_24x24.png "Tor")
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/ethon-impersonate.svg)](https://badge.fury.io/rb/ethon-impersonate)
6
+ [![Build Status](https://github.com/serpapi/ethon-impersonate/workflows/Ruby/badge.svg)](https://github.com/serpapi/ethon-impersonate/actions/workflows/ruby.yml)
7
+
8
+ **Ethon Impersonate** is a fork of [Ethon](https://github.com/typhoeus/ethon) that wraps [libcurl-impersonate](https://github.com/lexiforest/curl-impersonate).
9
+
10
+ In Greek mythology, Ethon, the son of Typhoeus and Echidna, is a gigantic eagle. So much for the history.
11
+
12
+ This allows you to make HTTP requests that appear to come from real browsers, helping to bypass bot detection and fingerprinting.
13
+
14
+ ## Installation
15
+
16
+ With bundler:
17
+ ```bash
18
+ gem "ethon-impersonate"
19
+ ```
20
+
21
+ With rubygems:
22
+ ```bash
23
+ gem install ethon-impersonate
24
+ ```
25
+
26
+ ## Dependencies
27
+ On MacOS Apple Silicon, you need to install the following dependencies using Homebrew:
28
+
29
+ ```bash
30
+ brew install libidn2 rtmpdump zstd
31
+ ```
32
+
33
+ Note: Homebrew must be loaded in the same arch than the Ruby interpreter. If you are using `arch -x86_64` to run Ruby, you must also run Homebrew with `arch -x86_64 brew install ...`.
34
+
35
+ ## Usage
36
+
37
+ Making the first request is simple:
38
+
39
+ ```ruby
40
+ easy = EthonImpersonate::Easy.new(url: "www.example.com")
41
+ easy.perform
42
+ #=> :ok
43
+ ```
44
+
45
+ You have access to various options, such as following redirects:
46
+
47
+ ```ruby
48
+ easy = EthonImpersonate::Easy.new(url: "www.example.com", followlocation: true)
49
+ easy.perform
50
+ #=> :ok
51
+ ```
52
+
53
+ Once you're done you can inspect the response code and body:
54
+
55
+ ```ruby
56
+ easy = EthonImpersonate::Easy.new(url: "www.example.com", followlocation: true)
57
+ easy.perform
58
+ easy.response_code
59
+ #=> 200
60
+ easy.response_body
61
+ #=> "<!doctype html><html ..."
62
+ ```
63
+
64
+ ## Browser Impersonation
65
+
66
+ The main feature of this gem is the ability to impersonate real browsers. Use the `impersonate` method to configure the request to look like it's coming from a specific browser:
67
+
68
+ ```ruby
69
+ easy = EthonImpersonate::Easy.new(url: "www.example.com")
70
+ easy.impersonate("chrome136") # Impersonate Chrome 136
71
+ easy.perform
72
+ easy.response_code
73
+ #=> 200
74
+ ```
75
+
76
+ ### Available Browser Targets
77
+
78
+ The gem supports all browser targets available in curl-impersonate. Some popular targets include:
79
+
80
+ - **Chrome**: `chrome136`, `chrome131_android`
81
+ - **Firefox**: `firefox135`
82
+ - **Safari**: `safari184`, `safari184_ios`
83
+ - **Edge**: `edge101`
84
+ - **Tor**: `tor145`
85
+
86
+ For a complete list of available targets, see the [curl-impersonate bin directory](https://github.com/lexiforest/curl-impersonate/tree/main/bin).
87
+
88
+ ### Example with Browser Impersonation
89
+
90
+ ```ruby
91
+ # Impersonate Chrome 136
92
+ easy = EthonImpersonate::Easy.new(url: "https://tls.browserleaks.com/json")
93
+ easy.impersonate("chrome136")
94
+ easy.perform
95
+ #=> :ok
96
+
97
+ # Impersonate Firefox 135
98
+ easy = EthonImpersonate::Easy.new(url: "https://tls.browserleaks.com/json")
99
+ easy.impersonate("firefox135")
100
+ easy.perform
101
+ #=> :ok
102
+
103
+ # Impersonate Safari 184
104
+ easy = EthonImpersonate::Easy.new(url: "https://tls.browserleaks.com/json")
105
+ easy.impersonate("safari184")
106
+ easy.perform
107
+ #=> :ok
108
+ ```
109
+
110
+ ## Http
111
+
112
+ In order to make life easier, there are some helpers for making HTTP requests:
113
+
114
+ ```ruby
115
+ easy = EthonImpersonate::Easy.new
116
+ easy.http_request("www.example.com", :get, { params: {a: 1} })
117
+ easy.perform
118
+ #=> :ok
119
+ ```
120
+
121
+ ```ruby
122
+ easy = EthonImpersonate::Easy.new
123
+ easy.http_request("www.example.com", :post, { params: { a: 1 }, body: { b: 2 } })
124
+ easy.perform
125
+ #=> :ok
126
+ ```
127
+
128
+ This is really handy when making requests since you don't have to care about setting
129
+ everything up correctly.
130
+
131
+ ## Http2
132
+ Standard http2 servers require the client to connect once and create a session (multi) and then add simple requests to the multi handler.
133
+ The `perform` method then takes all the requests in the multi handler and sends them to the server.
134
+
135
+ See the following example
136
+ ```ruby
137
+ multi = EthonImpersonate::Multi.new
138
+ easy = EthonImpersonate::Easy.new
139
+
140
+ easy.http_request("www.example.com/get", :get, { http_version: :httpv2_0 })
141
+
142
+ # Sending a request with http version 2 will send an Upgrade header to the server, which many older servers will not support
143
+ # See below for more info: https://everything.curl.dev/http/http2
144
+ # If this is a problem, send the below:
145
+ easy.http_request("www.example.com/get", :get, { http_version: :httpv2_prior_knowledge })
146
+
147
+ # To set the server to use http2 with https and http1 with http, send the following:
148
+ easy.http_request("www.example.com/get", :get, { http_version: :httpv2_tls })
149
+
150
+ multi.add(easy)
151
+ multi.perform
152
+ ```
153
+
154
+ ## Sponsors
155
+
156
+ Ethon Impersonate is maintained by **SerpApi**.
157
+
158
+ Thanks to all <a href="https://github.com/serpapi/ethon-impersonate/graphs/contributors">contributors</a> of this project past and present.
159
+
160
+ ------
161
+
162
+ <a href="https://serpapi.com/" target="_blank"><img src="https://raw.githubusercontent.com/serpapi/ethon-impersonate/master/assets/serpapi.png" alt="SerpAPI" height="67" width="63"></a>
163
+
164
+ Scrape Google and other search engines from [SerpApi](https://serpapi.com/)'s fast, easy, and complete API. 0.66s average response time (≤ 0.5s for Ludicrous Speed Max accounts), 99.95% SLAs, pay for successful responses only.
data/config/puma.rb ADDED
@@ -0,0 +1 @@
1
+ ENV['OBJC_DISABLE_INITIALIZE_FORK_SAFETY'] = 'YES'
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+ lib = File.expand_path("../lib/", __FILE__)
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+ require "ethon_impersonate/version"
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = "ethon-impersonate"
10
+ s.version = EthonImpersonate::VERSION
11
+ s.platform = Gem::Platform::RUBY
12
+ s.authors = ["David Sojevic", "Hans Hasselberg"]
13
+ s.email = ["david@sojevic.com"]
14
+ s.homepage = "https://github.com/serpapi/ethon-impersonate"
15
+ s.summary = "Impersonate browser-like HTTP requests."
16
+ s.description = "Realistic browser-like HTTP requests using curl-impersonate's impersonation capabilities."
17
+
18
+ s.required_ruby_version = ">= 2.7"
19
+ s.required_rubygems_version = ">= 1.3.6"
20
+ s.license = "MIT"
21
+
22
+ s.add_dependency("ffi", ["~> 1.15"])
23
+
24
+ s.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0")
26
+ end.reject { |file| file.start_with?(*%w[. Gemfile Guardfile Rakefile profile spec scripts assets]) || file.end_with?(".gitignore") }
27
+
28
+ s.require_path = "lib"
29
+ end
Binary file
@@ -0,0 +1 @@
1
+ require "ethon_impersonate"