Class: SeoTools::Engine::Base
- Inherits:
-
Object
- Object
- SeoTools::Engine::Base
- Defined in:
- lib/seotools/engine/base.rb
Overview
継承して各検索エンジンの解析クラスをつくる
Class Method Summary collapse
- .build_keyword(keyword) ⇒ Object
- .build_query(keyword, page = 1, uri = nil) ⇒ Object
- .get_number_of_index_results(uri) ⇒ Object
- .get_rank(uri, keyword, options = { }) ⇒ Object
- .request(keyword, page = 1, uri = nil, &block) ⇒ Object
- .uri ⇒ Object
Class Method Details
.build_keyword(keyword) ⇒ Object
18 19 20 |
# File 'lib/seotools/engine/base.rb', line 18 def self.build_keyword(keyword) CGI.escape(keyword.split(/\s/).join('+')) end |
.build_query(keyword, page = 1, uri = nil) ⇒ Object
13 14 15 16 |
# File 'lib/seotools/engine/base.rb', line 13 def self.build_query(keyword, page = 1, uri = nil) uri ||= self.uri uri.sub(Regexp.new(Regexp.quote('[%keyword%]')), self.build_keyword(keyword)) end |
.get_number_of_index_results(uri) ⇒ Object
36 37 38 |
# File 'lib/seotools/engine/base.rb', line 36 def self.get_number_of_index_results(uri) 0 end |
.get_rank(uri, keyword, options = { }) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/seotools/engine/base.rb', line 28 def self.get_rank(uri, keyword, = { }) = { :limit => 100 }.merge() self.search(uri, keyword, ) end |
.request(keyword, page = 1, uri = nil, &block) ⇒ Object
22 23 24 25 26 |
# File 'lib/seotools/engine/base.rb', line 22 def self.request(keyword, page = 1, uri = nil, &block) open(self.build_query(keyword, page, uri)) do |f| yield Hpricot(f.read) end end |
.uri ⇒ Object
9 10 11 |
# File 'lib/seotools/engine/base.rb', line 9 def self.uri "http://[%keyword%]" end |