class Query::Result::Qihu

Public Instance Methods

ads_bottom() click to toggle source
# File lib/query/result/qihu.rb, line 31
def ads_bottom
  []
end
ads_right() click to toggle source
# File lib/query/result/qihu.rb, line 35
def ads_right
  @page.search("//ul[@id='rightbox']/li").map.with_index do |li,index|
    a = li.search('a').first
    href = li.search("cite").first.text.downcase
    host = Addressable::URI.parse(URI.encode(href)).host
    next if a.text.include?'想在360推广您的产品服务吗'
    {
      :rank => index + 1,
      :text => a.text,
      :href => href,
      :host => host
    }
  end.compact
end
ads_top() click to toggle source
# File lib/query/result/qihu.rb, line 17
def ads_top
  @page.search("//ul[@id='djbox']/li").map.with_index do |li,index|
    a = li.search("a").first
    href = li.search("cite").first.text.downcase

    {
      :rank => index + 1,
      :text => a.text,
      :href => href,
      :host => Addressable::URI.parse(URI.encode(href)).host
    }
  end
end
blocked?() click to toggle source

被封

# File lib/query/result/qihu.rb, line 67
def blocked?
  @page.search('//ul[@id="m-result"]').first.nil? and @page.to_s.include?'您的请求暂时无法响应'
end
blocked_ip() click to toggle source

被封的IP

# File lib/query/result/qihu.rb, line 71
def blocked_ip
  (/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/.match @page.to_s).to_s
end
count() click to toggle source
# File lib/query/result/qihu.rb, line 54
def count
  @page.search('//span[@class="nums"]').first.text.gsub(/\D/,'').to_i
end
has_result?() click to toggle source

有结果

# File lib/query/result/qihu.rb, line 63
def has_result?
  !@page.search('//div[@id="main"]/h3').text().include?'没有找到该URL'
end
next_url() click to toggle source

下一页

# File lib/query/result/qihu.rb, line 59
def next_url
  next_href = @page.xpath('//a[@id="snext"]').first['href']
end
seo_ranks() click to toggle source
# File lib/query/result/qihu.rb, line 5
def seo_ranks
  @page.search('//ul[@id="m-result"]/li//h3').map.with_index do |h3,index|
    a = h3.search('a').first
    {
      :rank => index + 1,
      :href => a['href'],
      :text => a.text.strip,
      :host => Addressable::URI.parse(a['href']).host
    }
  end
end