Class: Page
- Inherits:
-
Bwkfanboy::Parse
- Object
- Bwkfanboy::Parse
- Page
- Defined in:
- lib/bwkfanboy/plugins/bwk.rb,
lib/bwkfanboy/plugins/quora.rb,
lib/bwkfanboy/plugins/econlib.rb,
lib/bwkfanboy/plugins/freebsd-ports-update.rb
Defined Under Namespace
Modules: Meta
Constant Summary
Constants inherited from Bwkfanboy::Parse
Instance Attribute Summary
Attributes inherited from Bwkfanboy::Parse
Instance Method Summary collapse
Methods inherited from Bwkfanboy::Parse
#check, #dump, #dump_info, #initialize, #parse, #to_json, #uri
Constructor Details
This class inherits a constructor from Bwkfanboy::Parse
Instance Method Details
#clean(t) ⇒ Object
21 22 23 24 25 |
# File 'lib/bwkfanboy/plugins/freebsd-ports-update.rb', line 21 def clean(t) t = t[2..-1] if t[0] != "\t" return '' if t == nil return t end |
#myadd(ready, t, l, u, a, c) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/bwkfanboy/plugins/freebsd-ports-update.rb', line 14 def myadd(ready, t, l, u, a, c) return true if ! ready return false if toobig? self << { title: t, link: l, updated: u, author: a, content: c.rstrip } if ready return true end |
#myparse(stream) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bwkfanboy/plugins/bwk.rb', line 17 def myparse(stream) url = "http://www.dailyprincetonian.com" doc = Nokogiri::HTML(stream, nil, Meta::ENC) doc.xpath("//div[@class='article_item']").each {|i| t = clean(i.xpath("h2/a").children.text()) fail 'unable to extract link' if (link = clean(i.xpath("h2/a")[0].attributes['href'].value()).empty?) link = clean(i.xpath("h2/a")[0].attributes['href'].value()) l = url + link + "print" u = date(i.xpath("h2").children[1].text()) a = clean(i.xpath("div/span/a[1]").children.text()) c = clean(i.xpath("div[@class='summary']").text()) self << { title: t, link: l, updated: u, author: a, content: c } } end |