Class: SeoTools::Engine::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/seotools/engine/base.rb

Overview

継承して各検索エンジンの解析クラスをつくる

Direct Known Subclasses

Google, Yahoo

Class Method Summary collapse

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, options = { })
	options = {
		:limit => 100
	}.merge(options)
	
	self.search(uri, keyword, options)
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

.uriObject



9
10
11
# File 'lib/seotools/engine/base.rb', line 9

def self.uri
	"http://[%keyword%]"
end