class Query::Result::Sogou

Public Instance Methods

ads_bottom() click to toggle source
# File lib/query/result/sogou.rb, line 28
def ads_bottom
  return [] if sponsored_divs.size < 2
end
ads_right() click to toggle source
# File lib/query/result/sogou.rb, line 17
              def ads_right
                      @page.css('div#right div#bdfs0').map.with_index do |div,index|
{
  :rank => index + 1,
  :text => div.css('h3 a').text,
  :href => div.css('h3 a')[0]['href'],
  :host => Addressable::URI.parse(div.css('div.fb a cite').text).host
}
                      end
              end
ads_top() click to toggle source
# File lib/query/result/sogou.rb, line 5
                def ads_top
return [] if sponsored_divs.empty?
sponsored_divs.first.search("li").map.with_index do|li,index|
                                {
    :rank => index + 1,
    :text => li.css('h3 a').text,
    :href => li.css('h3 a')[0]['href'],
    :host => Addressable::URI.parse(li.css('cite')[0].text).host
  }
                        end
                end
count() click to toggle source
# File lib/query/result/sogou.rb, line 44
def count
  node = @page.search("//resnum[@id='scd_num']").first
  node ? node.text.gsub(/\D/,'').to_i : nil
end
has_result?() click to toggle source
# File lib/query/result/sogou.rb, line 59
def has_result?
  @page.search("div[@class='no-result']").empty?
end
next_url() click to toggle source
# File lib/query/result/sogou.rb, line 53
def next_url
  next_btn = @page.search("//a[text()='下一页>']")
  return false if next_btn.empty?
  next_btn.first['href']
end
seo_ranks() click to toggle source
# File lib/query/result/sogou.rb, line 32
def seo_ranks
  # @seo_ranks ||= @page.search("div[@class='result']/div/h3").map do |h3|
  @page.search("//div[@class='results']/div/h3").map.with_index do |h3,index|
    {
      :text => h3.search('a').first.text,
      :href => h3.search('a').first['href'],
      :host => Addressable::URI.parse(h3.search('a').first['href']).host,
      :rank => index + 1
    }
  end
end

Private Instance Methods

sponsored_divs() click to toggle source
result

end