class FreeSpider::Spiders::Parser
Public Class Methods
new(url, css, attributes)
click to toggle source
# File lib/free_spider/spiders.rb, line 8 def initialize(url, css, attributes) @url = url @css = css @attributes = attributes end
Public Instance Methods
fetcher()
click to toggle source
# File lib/free_spider/spiders.rb, line 14 def fetcher html = open(@url).read doc = Nokogiri::HTML(html) # 找到网页中需要的内容 doc.css("#{@css}").map do |href| href.attributes["#{@attributes}"].value end end