Class: Query::Result::SogouMobile
- Inherits:
-
Object
- Object
- Query::Result::SogouMobile
show all
- Includes:
- Query::Result
- Defined in:
- lib/query/result/sogou_mobile.rb
Instance Attribute Summary
#baseuri, #pagenumber, #perpage
Instance Method Summary
collapse
#initialize, #next, #rank, #raw_ranks
Instance Method Details
#ads_bottom ⇒ Object
16
17
18
19
20
|
# File 'lib/query/result/sogou_mobile.rb', line 16
def ads_bottom
@page.search("//ul[@class='searchresult']/li[last()]/following-sibling::div").map.with_index do |div,index|
parse_ad(div).merge({:rank => index + 1})
end
end
|
#ads_right ⇒ Object
12
13
14
|
# File 'lib/query/result/sogou_mobile.rb', line 12
def ads_right
[]
end
|
#ads_top ⇒ Object
6
7
8
9
10
|
# File 'lib/query/result/sogou_mobile.rb', line 6
def ads_top
@page.search("//ul[@class='searchresult']/li[1]/preceding-sibling::div").map.with_index do |ad_div,index|
parse_ad(ad_div).merge({:rank => index + 1})
end
end
|
#count ⇒ Object
38
39
|
# File 'lib/query/result/sogou_mobile.rb', line 38
def count
end
|
#next_url ⇒ Object
34
35
36
|
# File 'lib/query/result/sogou_mobile.rb', line 34
def next_url
@page.search("//a[text()='下一页']").first['href']
end
|
#seo_ranks ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/query/result/sogou_mobile.rb', line 22
def seo_ranks
@seo_rank ||= @page.search("//ul[@class='searchresult']/li/a").map.with_index do |a,index|
href = URI.decode(CGI.parse(URI(URI.encode(a['href'])).query)['url'].first)
{
:rank => index + 1,
:text => a.search('h3').text,
:href => href,
:host => URI(href).host
}
end
end
|