class TinyGrabber
Main class for TinyGrabber
Net::HTTP agent for TinyGrabber
Initialize connect with Resource Setting connect attributes
Constants
- VERSION
Version number
Public Class Methods
Singleton > HTTP::GET request
@param url Resource link @param headers Request header
# File lib/tiny_grabber.rb, line 48 def self.get(url, config = {}) initialize config @agent.fetch url, :get end
Singleton > Initialize a new TinyGrabber
user agent.
# File lib/tiny_grabber.rb, line 21 def self.initialize(config = {}) @agent = TinyGrabber::Agent.new @agent.perfect_url = config[:perfect_url] if config[:perfect_url] @agent.debug = config[:debug] if config[:debug] @agent.read_timeout = config[:read_timeout] if config[:read_timeout] @agent.user_agent = config[:user_agent] if config[:user_agent] @agent.proxy = config[:proxy] if config[:proxy] @agent.basic_auth = config[:basic_auth] if config[:basic_auth] @agent.headers = config[:headers] if config[:headers] @agent.cookies = config[:cookies] if config[:cookies] end
Initialize a new TinyGrabber
user agent.
# File lib/tiny_grabber.rb, line 15 def initialize @agent = TinyGrabber::Agent.new end
Singleton > HTTP::GET request
@param url Resource link @param headers Request header
# File lib/tiny_grabber.rb, line 68 def self.post(url, params = {}, config = {}) initialize config @agent.fetch url, :post, {}, params end
Public Instance Methods
Set BASIC_AUTH agent attribute
@param username Authentification username @param password Authentification password
# File lib/tiny_grabber.rb, line 143 def basic_auth(username, password) @agent.basic_auth = { username: username, password: password } end
Set DEBUG flag
@param debug Flag to start debug
# File lib/tiny_grabber.rb, line 77 def debug=(debug) @agent.debug = debug end
Set follow_location
@param follow_location Follow location flag
# File lib/tiny_grabber.rb, line 193 def follow_location=(follow_location) @agent.follow_location = follow_location end
HTTP::GET request
@param url Resource link @param headers Request header
# File lib/tiny_grabber.rb, line 39 def get(url, headers = {}) @agent.fetch url, :get, headers end
Read HEADERS agent attribute
# File lib/tiny_grabber.rb, line 149 def headers @agent.headers.to_hash end
Set HEADERS agent attribute
@param headers Request headers
# File lib/tiny_grabber.rb, line 157 def headers=(headers) @agent.headers = headers end
Read perfect_url
agent attribute
# File lib/tiny_grabber.rb, line 83 def perfect_url @agent.perfect_url end
Set perfect_url
agent attribute
@param perfect_url
Removes additional processing url
# File lib/tiny_grabber.rb, line 91 def perfect_url=(perfect_url) @agent.perfect_url = perfect_url end
HTTP::POST request
@param url Resource link @param params Request post data @param headers Request header
# File lib/tiny_grabber.rb, line 59 def post(url, params = {}, headers = {}) @agent.fetch url, :post, headers, params end
Read PROXY agent attribute
# File lib/tiny_grabber.rb, line 126 def proxy @agent.proxy end
Set PROXY agent attribute
@param proxy Proxy configuration
# File lib/tiny_grabber.rb, line 134 def proxy=(proxy) @agent.proxy = proxy end
Read READ_TIMEOUT agent attribute
# File lib/tiny_grabber.rb, line 98 def read_timeout @agent.read_timeout end
Set READ_TIMEOUT agent attribute
@param read_timeout
Waiting time to reading
# File lib/tiny_grabber.rb, line 106 def read_timeout=(read_timeout) @agent.read_timeout = read_timeout end
Call RESET agent method
# File lib/tiny_grabber.rb, line 177 def reset @agent.reset end
Read URI
# File lib/tiny_grabber.rb, line 199 def uri @agent.uri end
Read USER_AGENT agent attribute
# File lib/tiny_grabber.rb, line 112 def user_agent @agent.user_agent end
Set USER_AGENT agent attribute
@param user_agent
Web browser name
# File lib/tiny_grabber.rb, line 120 def user_agent=(user_agent) @agent.user_agent = user_agent end
Set verify_mode
@param verify_mode SSL verify mode
# File lib/tiny_grabber.rb, line 185 def verify_mode=(verify_mode) @agent.verify_mode = verify_mode end