Class: Query::Result::SMobile

Inherits:
Object
  • Object
show all
Includes:
Query::Result
Defined in:
lib/query/result/sm_mobile.rb

Defined Under Namespace

Classes: XpathFunctions

Instance Attribute Summary

Attributes included from Query::Result

#baseuri, #options, #pagenumber, #perpage

Instance Method Summary collapse

Methods included from Query::Result

#initialize, #next, #rank, #raw_ranks

Instance Method Details

#ads_bottomObject



19
20
21
22
23
24
# File 'lib/query/result/sm_mobile.rb', line 19

def ads_bottom
  selector = "//div[@id='results']/div[@class='result card'][1]/following-sibling::div[@class='ali_row result card']"
  @ads_bottom ||= @page.search(selector).map.with_index do |ad_div,index|
    parse_ad(ad_div).merge({:rank => (index + 1) + (@pagenumber -1) * 10})
  end
end

#ads_rightObject



35
36
37
# File 'lib/query/result/sm_mobile.rb', line 35

def ads_right
  []
end

#ads_topObject



12
13
14
15
16
17
# File 'lib/query/result/sm_mobile.rb', line 12

def ads_top
  selector = "//div[@id='results']/div[@class='result card'][1]/preceding-sibling::div[@class='ali_row result card']"
  @ads_top ||= @page.search(selector).map.with_index do |ad_div,index|
    parse_ad(ad_div).merge({:rank => (index + 1) + (@pagenumber -1) * 10})
  end
end

#countObject



43
44
45
# File 'lib/query/result/sm_mobile.rb', line 43

def count

end

#htmlObject



31
32
33
# File 'lib/query/result/sm_mobile.rb', line 31

def html
  @page.to_html
end

#next_urlObject



39
40
41
# File 'lib/query/result/sm_mobile.rb', line 39

def next_url
  	"#{@baseuri.to_s}&page=#{@pagenumber+1}"
end

relative words



27
28
29
# File 'lib/query/result/sm_mobile.rb', line 27

def related_keywords
  @related_keywords ||= @page.search("//div[@class='rel-keywords card']/ul/li/a").map { |a| a.text }
end

#seo_ranksObject



6
7
8
9
10
# File 'lib/query/result/sm_mobile.rb', line 6

def seo_ranks
  @seo_ranks ||= @page.search("//div[@id='results']/div[@class!='ali_row result card']").map.with_index do |seo_div,index|
    parse_seo(seo_div).merge({:rank => (index + 1) + (@pagenumber -1) * 10})
  end
end