arachnid 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/arachnid.rb +14 -1
- metadata +1 -1
data/lib/arachnid.rb
CHANGED
@@ -15,6 +15,7 @@ class Arachnid
|
|
15
15
|
@split_url_at_hash = options[:split_url_at_hash] ? options[:split_url_at_hash] : false
|
16
16
|
@exclude_urls_with_hash = options[:exclude_urls_with_hash] ? options[:exclude_urls_with_hash] : false
|
17
17
|
@exclude_urls_with_extensions = options[:exclude_urls_with_extensions] ? options[:exclude_urls_with_extensions] : false
|
18
|
+
@proxy_list = options[:proxy_list] ? options[:proxy_list] : false
|
18
19
|
|
19
20
|
@debug = options[:debug] ? options[:debug] : false
|
20
21
|
end
|
@@ -38,7 +39,11 @@ class Arachnid
|
|
38
39
|
temp_queue.each do |q|
|
39
40
|
|
40
41
|
begin
|
41
|
-
|
42
|
+
ip,port,user,pass = grab_proxy
|
43
|
+
|
44
|
+
request = Typhoeus::Request.new(q, :timeout => 10000, :follow_location => true) if ip == nil
|
45
|
+
request = Typhoeus::Request.new(q, :timeout => 10000, :follow_location => true, :proxy => "#{ip}:#{port}") if ip != nil && user == nil
|
46
|
+
request = Typhoeus::Request.new(q, :timeout => 10000, :follow_location => true, :proxy => "#{ip}:#{port}", :proxy_username => user, :proxy_password => pass) if user != nil
|
42
47
|
|
43
48
|
request.on_complete do |response|
|
44
49
|
|
@@ -79,6 +84,14 @@ class Arachnid
|
|
79
84
|
|
80
85
|
end
|
81
86
|
|
87
|
+
def grab_proxy
|
88
|
+
|
89
|
+
return nil unless @proxy_list
|
90
|
+
|
91
|
+
return @proxy_list.sample.split(':')
|
92
|
+
|
93
|
+
end
|
94
|
+
|
82
95
|
def parse_domain(url)
|
83
96
|
puts "Parsing URL: #{url}" if @debug
|
84
97
|
|