class CatClaw::V2EXCat
Constants
- KEYWORD
Attributes
footprint[RW]
Public Class Methods
new()
click to toggle source
# File lib/cat_claw/cats/v2ex_cat.rb, line 8 def initialize @base_url = "http://v2ex.com" @footprint = { source: "V2EX", jobs: [], } end
Public Instance Methods
paw()
click to toggle source
# File lib/cat_claw/cats/v2ex_cat.rb, line 16 def paw 3.times do |i| whisper (i+1) end @footprint end
Private Instance Methods
whisper(page)
click to toggle source
# File lib/cat_claw/cats/v2ex_cat.rb, line 24 def whisper page puts 'opening URI ... v2ex' url = @base_url + "/go/jobs?p=" + page.to_s doc = Nokogiri::HTML(open(url)) topics = doc.css(".item_title a") topics.each do |t| if t.text.match KEYWORD url = @base_url + t.attr("href") doc = Nokogiri::HTML(open(url)) title = doc.css(".header h1").text content = doc.css(".topic_content").text @footprint[:jobs] << { url: url, title: title, content: content, scope: "China", job_type: "developer", } #p url #p title #p content #p "---" end end end