Class: HTTPal::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/rspider/browser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ua = "Mozilla/Firefox 2.0.11", max_len = 2048) ⇒ Browser

Returns a new instance of Browser.



28
29
30
31
32
33
34
35
# File 'lib/rspider/browser.rb', line 28

def initialize(ua="Mozilla/Firefox 2.0.11",max_len=2048)
	@cookies = []
	@referer = nil
	@userAgent=ua
	@max_len=max_len-1
	@open_timeout=5
	@read_timeout=5
end

Instance Attribute Details

#open_timeoutObject

Returns the value of attribute open_timeout.



27
28
29
# File 'lib/rspider/browser.rb', line 27

def open_timeout
  @open_timeout
end

#read_timeoutObject

Returns the value of attribute read_timeout.



27
28
29
# File 'lib/rspider/browser.rb', line 27

def read_timeout
  @read_timeout
end

Instance Method Details

#get(uri) ⇒ Object



41
42
43
44
45
# File 'lib/rspider/browser.rb', line 41

def get(uri)
	uri,path = parseuri(uri)
	req = Net::HTTP::Get.new(path)
	send_request(req, uri)
end

#post(uri, fields) ⇒ Object



47
48
49
50
51
52
# File 'lib/rspider/browser.rb', line 47

def post(uri, fields)
	uri,path = parseuri(uri)
	req = Net::HTTP::Post.new(path)
	req.set_form_data fields
	send_request(req, uri)
end

#use(&block) ⇒ Object



37
38
39
# File 'lib/rspider/browser.rb', line 37

def use(&block)
	instance_eval(&block)
end