mechanize 2.9.0 → 2.9.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
  SHA256:
3
- metadata.gz: 25fad3bc233e4efc5e99a66ccd480450e100b2bdb76e8a7e10d00ffb5386fcf0
4
- data.tar.gz: 6c63c1e76044803b26f687d48b12c3f43e2009afa7e5bbd6ce183e316eaad049
3
+ metadata.gz: 3090de20e06b18db1768b33b3f446a039d69b653002a03fc2576f8f821e996b5
4
+ data.tar.gz: 69f38522fee7861b2c39130a67e168b6b78c0d3d301e6f6d640d5cb175586486
5
5
  SHA512:
6
- metadata.gz: f200b8ceaac133254e05d03cbe38344cf31b55bd7c4a2979fd53580eb5fb84ee4f04e4a76e111037cc6d1e6efdeabb14a494ff47194668dc8334d06dc26cd377
7
- data.tar.gz: af78f50d64366a713f70297befb328cba35120b08850c99cf2dd09a2d670b1ffcdf5cf5e12889e12db2c7ddc7a595074707c58e7aa0c4792693cbf5cddacee3e
6
+ metadata.gz: a11a74bb5118f20cd4a31673f40595882192b8c84d33d6bf6d116e007afe6e369ce7ae7f1dc832f34a94d6dc7a2732c82462351f62b53bdaab0ed6bcf2ea8bd6
7
+ data.tar.gz: 2bc5af7fb18fcdffa84f255777317f1729b454dc3f8539de27ad172991c49c250de457464691d63c85c32006ecb4105137b653f1c78ea948425e54aa562b2b98
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Mechanize CHANGELOG
2
2
 
3
+ ## 2.9.1 / 2023-04-17
4
+
5
+ ### Update
6
+
7
+ * Updated User-Agent strings to represent modern browser versions. (#612) Thank you, @takatea!
8
+
9
+
3
10
  ## 2.9.0 / 2023-04-07
4
11
 
5
12
  ### Requirements
@@ -0,0 +1,91 @@
1
+ require 'mechanize'
2
+
3
+ class LatestUAFetcher
4
+ attr_reader :user_agents
5
+
6
+ BASE_URL = 'https://www.whatismybrowser.com/guides/the-latest-user-agent'
7
+
8
+ def initialize
9
+ @agent = Mechanize.new.tap { |a| a.user_agent_alias = 'Mac Firefox' }
10
+ @user_agents = {}
11
+ end
12
+
13
+ def run
14
+ sleep_time = 1
15
+
16
+ puts 'get chrome UA...'
17
+ chrome
18
+ puts "sleeping... (#{sleep_time}s)"
19
+ sleep 1
20
+
21
+ puts 'get firefox UA...'
22
+ firefox
23
+ puts "sleeping... (#{sleep_time}s)"
24
+ sleep 1
25
+
26
+ puts 'get safari UA...'
27
+ safari
28
+ puts "sleeping... (#{sleep_time}s)"
29
+ sleep 1
30
+
31
+ puts 'get edge UA...'
32
+ edge
33
+ end
34
+
35
+ private
36
+
37
+ def edge
38
+ page = @agent.get("#{BASE_URL}/edge")
39
+
40
+ windows_dom = page.css("h2:contains('Latest Edge on Windows User Agents')")
41
+ @user_agents[:edge] = {
42
+ windows: windows_dom.css('+ .listing-of-useragents .code').first.text
43
+ }
44
+ end
45
+
46
+ def firefox
47
+ page = @agent.get("#{BASE_URL}/firefox")
48
+
49
+ desktop_dom = page.css("h2:contains('Latest Firefox on Desktop User Agents')")
50
+ table_dom = desktop_dom.css('+ .listing-of-useragents')
51
+
52
+ @user_agents[:firefox] = {
53
+ windows: table_dom.css('td:contains("Windows")').css('+ td .code').text,
54
+ macOS: table_dom.css('td:contains("Macos")').css('+ td .code').text,
55
+ linux: table_dom.css('td:contains("Linux")').css("+ td .code:contains('Ubuntu; Linux x86_64')").text
56
+ }
57
+ end
58
+
59
+ def safari
60
+ page = @agent.get("#{BASE_URL}/safari")
61
+
62
+ macos_dom = page.css("h2:contains('Latest Safari on macOS User Agents')")
63
+ ios_dom = page.css("h2:contains('Latest Safari on iOS User Agents')")
64
+
65
+ @user_agents[:safari] = {
66
+ mac_os: macos_dom.css('+ .listing-of-useragents .code').first.text,
67
+ iphone: ios_dom.css('+ .listing-of-useragents').css("tr:contains('Iphone') .code").text,
68
+ ipad: ios_dom.css('+ .listing-of-useragents').css("tr:contains('Ipad') .code").text
69
+ }
70
+ end
71
+
72
+ def chrome
73
+ page = @agent.get("#{BASE_URL}/chrome")
74
+
75
+ windows_dom = page.css("h2:contains('Latest Chrome on Windows 10 User Agents')")
76
+ linux_dom = page.css("h2:contains('Latest Chrome on Linux User Agents')")
77
+ macos_dom = page.css("h2:contains('Latest Chrome on macOS User Agents')")
78
+ android_dom = page.css("h2:contains('Latest Chrome on Android User Agents')")
79
+
80
+ @user_agents[:chrome] = {
81
+ windows: windows_dom.css('+ .listing-of-useragents .code').first.text,
82
+ linux: linux_dom.css('+ .listing-of-useragents .code').first.text,
83
+ mac_os: macos_dom.css('+ .listing-of-useragents .code').first.text,
84
+ android: android_dom.css('+ .listing-of-useragents .code').first.text
85
+ }
86
+ end
87
+ end
88
+
89
+ agent = LatestUAFetcher.new
90
+ agent.run
91
+ p agent.user_agents
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class Mechanize
3
- VERSION = "2.9.0"
3
+ VERSION = "2.9.1"
4
4
  end
data/lib/mechanize.rb CHANGED
@@ -87,54 +87,73 @@ class Mechanize
87
87
  # description in parenthesis is for informative purposes and is not part of
88
88
  # the alias name.
89
89
  #
90
- # * Linux Firefox (43.0 on Ubuntu Linux)
91
- # * Linux Konqueror (3)
92
- # * Linux Mozilla
93
- # * Mac Firefox (43.0)
94
- # * Mac Mozilla
95
- # * Mac Safari (9.0 on OS X 10.11.2)
96
- # * Mac Safari 4
97
- # * Mechanize (default)
98
- # * Windows IE 6
99
- # * Windows IE 7
100
- # * Windows IE 8
101
- # * Windows IE 9
102
- # * Windows IE 10 (Windows 8 64bit)
103
- # * Windows IE 11 (Windows 8.1 64bit)
104
- # * Windows Edge
105
- # * Windows Mozilla
106
- # * Windows Firefox (43.0)
107
- # * iPhone (iOS 9.1)
108
- # * iPad (iOS 9.1)
109
- # * Android (5.1.1)
90
+ # The default User-Agent alias:
91
+ #
92
+ # * "Mechanize"
93
+ #
94
+ # Linux User-Agent aliases:
95
+ #
96
+ # * "Linux Firefox"
97
+ # * "Linux Konqueror"
98
+ # * "Linux Mozilla"
99
+ #
100
+ # Mac User-Agent aliases:
101
+ #
102
+ # * "Mac Firefox"
103
+ # * "Mac Mozilla"
104
+ # * "Mac Safari 4"
105
+ # * "Mac Safari"
106
+ #
107
+ # Windows User-Agent aliases:
108
+ #
109
+ # * "Windows Edge"
110
+ # * "Windows Firefox"
111
+ # * "Windows IE 6"
112
+ # * "Windows IE 7"
113
+ # * "Windows IE 8"
114
+ # * "Windows IE 9"
115
+ # * "Windows IE 10"
116
+ # * "Windows IE 11"
117
+ # * "Windows Mozilla"
118
+ #
119
+ # Mobile User-Agent aliases:
120
+ #
121
+ # * "Android"
122
+ # * "iPad"
123
+ # * "iPhone"
110
124
  #
111
125
  # Example:
112
126
  #
113
127
  # agent = Mechanize.new
114
128
  # agent.user_agent_alias = 'Mac Safari'
115
-
129
+ #
116
130
  AGENT_ALIASES = {
131
+ # TODO: use output from examples/latest_user_agents.rb as the underling data structure
117
132
  'Mechanize' => "Mechanize/#{VERSION} Ruby/#{ruby_version} (http://github.com/sparklemotion/mechanize/)",
118
- 'Linux Firefox' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0',
133
+
134
+ 'Linux Firefox' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:112.0) Gecko/20100101 Firefox/112.0',
119
135
  'Linux Konqueror' => 'Mozilla/5.0 (compatible; Konqueror/3; Linux)',
120
136
  'Linux Mozilla' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624',
121
- 'Mac Firefox' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0',
137
+
138
+ 'Mac Firefox' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13.3; rv:112.0) Gecko/20100101 Firefox/112.0',
122
139
  'Mac Mozilla' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4a) Gecko/20030401',
123
140
  'Mac Safari 4' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; de-at) AppleWebKit/531.21.8 (KHTML, like Gecko) Version/4.0.4 Safari/531.21.10',
124
- 'Mac Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9',
125
- 'Windows Chrome' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.125 Safari/537.36',
141
+ 'Mac Safari' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15',
142
+
143
+ 'Windows Chrome' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
144
+ 'Windows Edge' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.46',
145
+ 'Windows Firefox' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:112.0) Gecko/20100101 Firefox/112.0',
126
146
  'Windows IE 6' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
127
147
  'Windows IE 7' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
128
148
  'Windows IE 8' => 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
129
149
  'Windows IE 9' => 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
130
150
  'Windows IE 10' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)',
131
151
  'Windows IE 11' => 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko',
132
- 'Windows Edge' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586',
133
152
  'Windows Mozilla' => 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4b) Gecko/20030516 Mozilla Firebird/0.6',
134
- 'Windows Firefox' => 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0',
135
- 'iPhone' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B5110e Safari/601.1',
136
- 'iPad' => 'Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
137
- 'Android' => 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 7 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.76 Safari/537.36',
153
+
154
+ 'Android' => 'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.48 Mobile Safari/537.36',
155
+ 'iPad' => 'Mozilla/5.0 (iPad; CPU OS 16_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1',
156
+ 'iPhone' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Mobile/15E148 Safari/604.1',
138
157
  }
139
158
 
140
159
  AGENT_ALIASES.default_proc = proc { |hash, key|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mechanize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2023-04-07 00:00:00.000000000 Z
15
+ date: 2023-04-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: addressable
@@ -279,6 +279,7 @@ files:
279
279
  - README.md
280
280
  - Rakefile
281
281
  - examples/flickr_upload.rb
282
+ - examples/latest_user_agents.rb
282
283
  - examples/mech-dump.rb
283
284
  - examples/proxy_req.rb
284
285
  - examples/rubygems.rb