curl 0.0.3 → 0.0.4
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.
Potentially problematic release.
This version of curl might be problematic. Click here for more details.
- data/lib/curl.rb +27 -28
- metadata +4 -4
data/lib/curl.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
2
|
require 'cgi'
|
3
3
|
require "open3"
|
4
4
|
require 'fileutils'
|
@@ -10,28 +10,27 @@ include Open3
|
|
10
10
|
|
11
11
|
|
12
12
|
class CURL
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
AGENT_ALIASES = {
|
14
|
+
'Windows IE 6' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
|
15
|
+
'Windows IE 7' => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)',
|
16
|
+
'Windows Mozilla' => 'Mozilla/5.0 Windows; U; Windows NT 5.0; en-US; rv:1.4b Gecko/20030516 Mozilla Firebird/0.6',
|
17
|
+
'Windows Mozilla 2' => 'Mozilla/5.0 Windows; U; Windows NT 5.0; ru-US; rv:1.4b Gecko/20030516',
|
18
|
+
'Windows Mozilla 3' => 'Mozilla/5.0 Windows; U; Windows NT 5.0; en-UK; rv:1.4b Gecko/20060516',
|
19
|
+
'Mac Safari' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418 (KHTML, like Gecko) Safari/417.9.3',
|
20
|
+
'Mac FireFox' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3',
|
21
|
+
'Mac Mozilla' => 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4a) Gecko/20030401',
|
22
|
+
'Linux Mozilla' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624',
|
23
|
+
'Linux Konqueror' => 'Mozilla/5.0 (compatible; Konqueror/3; Linux)',
|
24
|
+
'IPhone' => 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3',
|
25
|
+
'IPhone Vkontakt' => 'VKontakte/1.1.8 CFNetwork/342.1 Darwin/9.4.1',
|
26
26
|
'Google'=>"Googlebot/2.1 (+http://www.google.com/bot.html)",
|
27
27
|
"Yahoo-Slurp"=>"Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)"
|
28
28
|
|
29
|
-
|
29
|
+
}
|
30
30
|
|
31
31
|
attr_accessor :user_agent
|
32
32
|
|
33
33
|
def initialize(keys={})
|
34
|
-
#@debug = true
|
35
34
|
@cache = ( keys[:cache] ? keys[:cache] : false )
|
36
35
|
@cookies_enable = ( keys[:cookies_disable] ? false : true )
|
37
36
|
@user_agent = AGENT_ALIASES["Google"]#AGENT_ALIASES[AGENT_ALIASES.keys[rand(6)]]
|
@@ -204,18 +203,18 @@ class CURL
|
|
204
203
|
end
|
205
204
|
|
206
205
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
206
|
+
def clear
|
207
|
+
File.delete(@cookies_file) if File.exists?(@cookies_file)
|
208
|
+
end
|
209
|
+
|
210
|
+
def init_cook(hash,site='')
|
211
|
+
file = "# Netscape HTTP Cookie File\n# http://curl.haxx.se/rfc/cookie_spec.html\n# This file was generated by libcurl! Edit at your own risk.\n\n"
|
212
|
+
hash.each do |key,val|
|
213
|
+
file += "#{site}\tTRUE\t/\tFALSE\t0\t#{key}\t#{val}\n"
|
214
|
+
end
|
215
|
+
File.open(cookies_store.scan(/\"(.+?)\"/).first.first,"w") {|f| f.puts file+"\n" }
|
216
|
+
file+"\n"
|
217
|
+
end
|
219
218
|
|
220
219
|
|
221
220
|
private
|
metadata
CHANGED
@@ -5,12 +5,12 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- tg0
|
13
|
-
autorequire:
|
13
|
+
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: "0"
|
72
72
|
requirements: []
|
73
73
|
|
74
|
-
rubyforge_project:
|
74
|
+
rubyforge_project: curl
|
75
75
|
rubygems_version: 1.3.7
|
76
76
|
signing_key:
|
77
77
|
specification_version: 3
|