Method: CURL#initialize

Defined in:
lib/curl.rb

#initialize(keys = {}) {|_self| ... } ⇒ CURL

Returns a new instance of CURL.

Yields:

  • (_self)

Yield Parameters:

  • _self (CURL)

    the object that the method was called on



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/curl.rb', line 34

def initialize(keys={})
   @socks_hostname = keys[:socks_hostname] ||= false
   @cache = ( keys[:cache] ? keys[:cache] : false  )
   @cache_time = ( keys[:cache_time] ? keys[:cache_time] : 3600*24*1  ) # 1 day cache life
   @connect_timeout = keys[:connect_timeout] || 6
   @max_time = keys[:max_time] || 8
   @retry = keys[:retry] || 1
   @cookies_enable = ( keys[:cookies_disable] ? false : true  )
         @user_agent     = AGENT_ALIASES["Google"]#AGENT_ALIASES[AGENT_ALIASES.keys[rand(6)]]
         FileUtils.makedirs("/tmp/curl/")
   @cookies_file = keys[:cookies] || "/tmp/curl/curl_#{rand}_#{rand}.jar"
   # @cookies_file	= "/home/ruslan/curl.jar"		
   #--header "Accept-Encoding: deflate"
#    @setup_params	= ' --header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" --header "Accept-Language: en-us,en;q=0.5" --header "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" '
   @setup_params	= " --connect-timeout #{@connect_timeout}  --max-time #{@max_time} --retry #{@retry}  --location --compressed --silent -k "
#		@setup_params	= ' --location --silent  '
	yield self if block_given?		
end