Class: Jaleb::Data
- Inherits:
-
Object
- Object
- Jaleb::Data
- Defined in:
- lib/jaleb/data.rb
Overview
this class is responsible for fetching and parsing data
Class Method Summary collapse
-
.read(url) ⇒ Object
Get read url and get data object.
Class Method Details
.read(url) ⇒ Object
Get read url and get data object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jaleb/data.rb', line 9 def self.read(url ) opt= {} opt['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36' response = open(url, opt) doc = ::Nokogiri::HTML(response.read) # Save contents of URL/Remote File for debugging response.rewind last_response_file = File.(File.join("..", "..", "last_response"), File.dirname(__FILE__)) File.new(last_response_file, "w+").write(response.read) return doc end |