Class: HttpCrawler::Proxy::TestProxyApi::Client

Inherits:
Client show all
Defined in:
lib/http_crawler/proxy/test_proxy_api/client.rb

Instance Attribute Summary

Attributes inherited from Client

#all_timeout, #connect_time, #cookies, #error_urls, #header, #max_error_num, #read_time, #redirect, #response, #uri, #write_time

Instance Method Summary collapse

Methods inherited from Client

for, #max_error_num

Methods inherited from Client

#add_error_url, #auto_proxy=, for, for_module, for_uri, #get, #get_uri, #http, #inheritance_cookies, #init_client, #init_cookies, #init_header, #init_ssl, #init_timeout, #initialize, #post, #proxy_api, #proxy_params, #remove_traces, #replace_header, #update_cookies, #update_header, #update_proxy, #update_proxy?, #update_uri, #validation_to_proxy?

Constructor Details

This class inherits a constructor from HttpCrawler::Client

Instance Method Details

#get_proxy(parameter = {}) ⇒ Object



21
22
23
24
# File 'lib/http_crawler/proxy/test_proxy_api/client.rb', line 21

def get_proxy(parameter = {})
  r = http.get("/api/get_proxy")
  r.extend(HttpCrawler::Proxy::TestProxyApi::Response::GetProxy)
end

#init_uriObject

这是个错误代码 http类不能唯一,如果唯一的话高并发情况下会导致前一个请求未结束,下一个请求已经在发送,会出现冲突 class << self

def new(*args)
  @client ||= super(*args)
end

end



16
17
18
# File 'lib/http_crawler/proxy/test_proxy_api/client.rb', line 16

def init_uri
  @uri = URI("http://127.0.0.1:1111/")
end