Module: Tsumamigui

Defined in:
lib/tsumamigui.rb,
lib/tsumamigui/error.rb,
lib/tsumamigui/parser.rb,
lib/tsumamigui/request.rb,
lib/tsumamigui/version.rb,
lib/tsumamigui/response.rb

Defined Under Namespace

Classes: Parser, ParserError, Request, RequestError, Response

Constant Summary collapse

VERSION =
'0.1.3'.freeze

Class Method Summary collapse

Class Method Details

.scrape(url, xpath) ⇒ Array

Returns parsed contents.

Examples:

Tsumamigui.scrape('http://example.com', title: '//div[0]/@content')
# you can specify muitiple urls at once
urls = ['http://example.com', 'http://example.com/sample']
Tsumamigui.scrape(urls, title: '//div[0]/@content')

Parameters:

  • url (String)
  • url (Array<String>)
  • xpath (Hash)

    key and xpath to it

Returns:

  • (Array)

    parsed contents



16
17
18
19
# File 'lib/tsumamigui.rb', line 16

def scrape(url, xpath)
  documents = Request.run(url)
  Parser.parse(documents, xpath)
end