tweakphoeus 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc7932bfc55944db175b78337a59df4b85cc72a9
4
- data.tar.gz: d0653d3ba555dc2350566feb180bab522454d412
3
+ metadata.gz: 7515558791d3bb44e239251dc6d0c6e80e7f5016
4
+ data.tar.gz: ce23946d37d62c994beeb79fa8c2f8a608419ff9
5
5
  SHA512:
6
- metadata.gz: 265cb93e198231d4da9d1b225b38cda425182d509d687873078e82fcdceb3b871e08218408b569fb0b532788237515771fa4b56935cde0346b1bdb11e851c359
7
- data.tar.gz: 05c35d848ea2cc788e88ad03065fa197b8e929272e079639c1ebc450ff3de5b40a36e7b15b52640e9b0b072e26cc31354e3b7a8b58ed644bebc2689ad263473a
6
+ metadata.gz: 791dc3839b5f832b7c4eb340adb97e3f781e0075d5f4ec49f28358547949892b9e21e0b9e43b09a52214328535a562b1a19b60bf380e6204be5b8dfaef19680f
7
+ data.tar.gz: ce4966aca13bb4c2b081f8c7963536342e018c6c4a2cec9b26d025065ab19f07cee61628329d8e10e5094c7e751b745e3e899607ceace9803324459b8e1122f8
data/CHANGELOG.md CHANGED
@@ -1,8 +1,17 @@
1
1
  -- v0.1.0 - First stable version: Typhoeus dependency version updated
2
+
2
3
  -- v0.2.0 - Refactor of cookies format
4
+
3
5
  -- v0.2.1 - Add accessor for base headers and merge method
6
+
4
7
  -- v0.2.2 - delete method added, thanks @pablobfonseca
8
+
5
9
  -- v0.2.3 - adding parameter params in order to handle in_url parameters
10
+
6
11
  -- v0.2.4 - adding parametes to post requests
12
+
7
13
  -- v0.2.5 - adding public method cookie_string
14
+
8
15
  -- v0.3.0 - adding HTTP proxy management and fixing circular reference
16
+
17
+ -- v0.4.1 - adding random User-Agent generator
@@ -0,0 +1,38 @@
1
+ module Tweakphoeus
2
+ class UserAgent
3
+ OS_DATA = {
4
+ types: [:win, :linux, :mac],
5
+ linux_distro: ["Ubuntu", "Debian", "Fedora", "gNewSense", "Linux Mint", "OpenSUSE", "Mandriva"],
6
+ arch: ["x86", "x86_64"],
7
+ win_arch: ["Win64; x64", "WOW64"]
8
+ }
9
+
10
+ class << self
11
+ def random(systems: OS_DATA[:types])
12
+ user_agent = "Mozilla/5.0 (#{os[systems.sample]}) #{browser}"
13
+ firefox_version = user_agent.match(/Firefox\/([0-9\.]+)/).try(:[], 1)
14
+ user_agent.gsub!(')', "; rv:#{firefox_version})") if firefox_version
15
+ user_agent
16
+ end
17
+
18
+ private
19
+
20
+ def os
21
+ {
22
+ win: "Windows NT #{%w(5 6 7 8 10).sample + '.' + %w(0 1).sample}",
23
+ linux: "X11; #{["", OS_DATA[:linux_distro].sample+"; "].sample}Linux #{OS_DATA[:arch].sample}",
24
+ mac: "Macintosh; Intel Mac OS X 10_#{Random.rand(9..12)}_#{Random.rand(0..5)}"
25
+ }
26
+ end
27
+
28
+ def browser
29
+ chrome_version = "Chrome/5#{Random.rand(0..9)}.0.#{Random.rand(1000..4000)}.#{Random.rand(100..900)}"
30
+ webkit_603 = "603.#{Random.rand(0..9)}.#{Random.rand(0..9)}"
31
+ ["Gecko/20100101 Firefox/#{Random.rand(40..54)}.#{Random.rand(0..9)}",
32
+ "AppleWebKit/537.36 (KHTML, like Gecko) #{chrome_version} Safari/537.36",
33
+ "AppleWebKit/#{webkit_603} (KHTML, like Gecko) Version/10.1 #{chrome_version} Safari/#{webkit_603}"
34
+ ].sample
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module Tweakphoeus
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/lib/tweakphoeus.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "tweakphoeus/version"
2
+ require "tweakphoeus/user_agent"
2
3
  require "typhoeus"
3
4
 
4
5
  module Tweakphoeus
@@ -10,7 +11,7 @@ module Tweakphoeus
10
11
  @cookie_jar = {}
11
12
  @referer = [""]
12
13
  @base_headers = {
13
- "User-Agent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0",
14
+ "User-Agent" => UserAgent.random(systems: [:linux, :mac]),
14
15
  "Accept-Language" => "es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3",
15
16
  "Accept-Encoding" => "",
16
17
  "Connection" => "keep-alive"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tweakphoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Martin Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-05 00:00:00.000000000 Z
11
+ date: 2017-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -97,6 +97,7 @@ files:
97
97
  - bin/console
98
98
  - bin/setup
99
99
  - lib/tweakphoeus.rb
100
+ - lib/tweakphoeus/user_agent.rb
100
101
  - lib/tweakphoeus/version.rb
101
102
  - tweakphoeus.gemspec
102
103
  homepage: https://github.com/basestylo/Tweakphoeus/