seo_checker 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -0
- data/VERSION +1 -1
- data/lib/seo_checker.rb +58 -31
- data/seo_checker.gemspec +68 -0
- metadata +30 -22
data/README.md
CHANGED
@@ -5,11 +5,19 @@ Check your website if it is seo.
|
|
5
5
|
## Checklists
|
6
6
|
|
7
7
|
- use sitemap file
|
8
|
+
- each page are reachable
|
9
|
+
- each page has title
|
8
10
|
- use unique title tags for each page
|
11
|
+
- each page has meta description
|
9
12
|
- ues unique descriptions for each page
|
13
|
+
- url does not just use ID number.
|
10
14
|
- url does not use excessive keywords
|
11
15
|
- url does not have deep nesting of subdirectories
|
12
16
|
|
17
|
+
## Install
|
18
|
+
|
19
|
+
<code>sudo gem install seo_checker</code>
|
20
|
+
|
13
21
|
## Usage
|
14
22
|
|
15
23
|
It is easy to use, just one line.
|
@@ -24,3 +32,8 @@ Usage: seo_checker [OPTIONS] website_url
|
|
24
32
|
-h, --help Show this message
|
25
33
|
</code></pre>
|
26
34
|
|
35
|
+
For example:
|
36
|
+
|
37
|
+
<pre><code>seo_checker http://localhost:3000</code></pre>
|
38
|
+
|
39
|
+
<pre><code>seo_checker http://yoursite.com -b 10 -i 1</code></pre>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/seo_checker.rb
CHANGED
@@ -11,9 +11,14 @@ class SEOChecker
|
|
11
11
|
@locations = []
|
12
12
|
@titles = {}
|
13
13
|
@descriptions = {}
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
14
|
+
@id_urls = {}
|
15
|
+
@excessive_keywords = []
|
16
|
+
@nesting_subdirectories = []
|
17
|
+
@no_titles = []
|
18
|
+
@no_descriptions = []
|
19
|
+
@unreachables = []
|
20
|
+
@batch_size = options[:batch_size] ? options[:batch_size].to_i : nil
|
21
|
+
@interval_time = options[:interval_time].to_i
|
17
22
|
end
|
18
23
|
|
19
24
|
def check
|
@@ -45,31 +50,22 @@ class SEOChecker
|
|
45
50
|
batch_locations.each do |location|
|
46
51
|
response = get_response(URI.parse(location))
|
47
52
|
if response.is_a? Net::HTTPSuccess
|
48
|
-
|
49
|
-
|
53
|
+
if response.body =~ %r{<head>(.*?)</head>}m
|
54
|
+
check_title($1, location)
|
55
|
+
check_description($1, location)
|
56
|
+
else
|
57
|
+
@no_titles << location
|
58
|
+
@no_descriptions << location
|
59
|
+
end
|
50
60
|
check_url(location)
|
51
61
|
else
|
52
|
-
@
|
62
|
+
@unreachables << location
|
53
63
|
end
|
54
64
|
end
|
55
65
|
sleep(@interval_time)
|
56
66
|
end
|
57
67
|
end
|
58
68
|
|
59
|
-
def report
|
60
|
-
@titles.each do |title, locations|
|
61
|
-
if locations.size > 1
|
62
|
-
@errors << "#{locations.slice(0, 5).join(', ')} #{'and ...' if locations.size > 5} have the same title '#{title}'."
|
63
|
-
end
|
64
|
-
end
|
65
|
-
@descriptions.each do |description, locations|
|
66
|
-
if locations.size > 1
|
67
|
-
@errors << "#{locations.slice(0, 5).join(', ')} #{'and ...' if locations.size > 5} have the same description '#{description}'."
|
68
|
-
end
|
69
|
-
end
|
70
|
-
puts @errors.join("\n")
|
71
|
-
end
|
72
|
-
|
73
69
|
private
|
74
70
|
def get_response(uri)
|
75
71
|
http = Net::HTTP.new(uri.host, uri.port)
|
@@ -78,34 +74,65 @@ class SEOChecker
|
|
78
74
|
response = http.request(request)
|
79
75
|
end
|
80
76
|
|
81
|
-
def check_title(
|
82
|
-
if
|
77
|
+
def check_title(header_string, location)
|
78
|
+
if header_string =~ %r{<title>(.*?)</title>}
|
83
79
|
title = $1
|
80
|
+
(@titles[title] ||= []) << location
|
84
81
|
else
|
85
|
-
@
|
82
|
+
@no_titles << location
|
86
83
|
end
|
87
|
-
(@titles[title] ||= []) << location
|
88
84
|
end
|
89
85
|
|
90
|
-
def check_description(
|
91
|
-
if
|
86
|
+
def check_description(header_string, location)
|
87
|
+
if header_string =~ %r{<meta\s+name=["']description["']\s+content=["'](.*?)["']\s*/>|<meta\s+content=["'](.*?)["']\s+name=["']description["']\s*/>}
|
92
88
|
description = $1 || $2
|
89
|
+
(@descriptions[description] ||= []) << location
|
93
90
|
else
|
94
|
-
@
|
91
|
+
@no_descriptions << location
|
95
92
|
end
|
96
|
-
(@descriptions[description] ||= []) << location
|
97
93
|
end
|
98
94
|
|
99
95
|
def check_url(location)
|
100
96
|
items = location.split('/')
|
101
97
|
if items.find { |item| item =~ /^\d+$/ } || items.last =~ /^\d+\.htm(l)?/
|
102
|
-
@
|
98
|
+
@id_urls[location.gsub(%r{/\d+/}, 'id')] = location
|
103
99
|
end
|
104
100
|
if items.find { |item| item.split('-').size > 5 }
|
105
|
-
@
|
101
|
+
@excessive_keywords << location
|
106
102
|
end
|
107
103
|
if items.size > 8
|
108
|
-
@
|
104
|
+
@nesting_subdirectories << location
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def report
|
109
|
+
unless @unreachables.empty?
|
110
|
+
print "#{@unreachables.slice(0, 5).join(",\n")} #{'and ...' if @unreachables.size > 5} are unreachable.\n\n"
|
111
|
+
end
|
112
|
+
unless @no_titles.empty?
|
113
|
+
print "#{@no_titles.slice(0, 5).join(",\n")} #{'and ...' if @no_titles.size > 5} have no title.\n\n"
|
114
|
+
end
|
115
|
+
unless @no_descriptions.empty?
|
116
|
+
print "#{@no_descriptions.slice(0, 5).join(",\n")} #{'and ...' if @no_descriptions.size > 5} have no description.\n\n"
|
117
|
+
end
|
118
|
+
@titles.each do |title, locations|
|
119
|
+
if locations.size > 1
|
120
|
+
print "#{locations.slice(0, 5).join(",\n")} #{'and ...' if locations.size > 5} have the same title '#{title}'.\n\n"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
@descriptions.each do |description, locations|
|
124
|
+
if locations.size > 1
|
125
|
+
print "#{locations.slice(0, 5).join(",\n")} #{'and ...' if locations.size > 5} have the same description '#{description}'.\n\n"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
unless @id_urls.empty?
|
129
|
+
print "#{@id_urls.values.slice(0, 5).join(",\n")} #{'and ...' if @id_urls.values.size > 5} use ID number in URL.\n\n"
|
130
|
+
end
|
131
|
+
unless @excessive_keywords.empty?
|
132
|
+
print "#{@excessive_keywords.slice(0, 5).join(",\n")} #{'and ...' if @excessive_keywords.size > 5} use excessive keywords in URL.\n\n"
|
133
|
+
end
|
134
|
+
unless @nesting_subdirectories.empty?
|
135
|
+
print "#{@nesting_subdirectories.slice(0, 5).join(",\n")} #{'and ...' if @nesting_subdirectories.size > 5} have deep nesting of subdirectories in URL.\n\n"
|
109
136
|
end
|
110
137
|
end
|
111
138
|
end
|
data/seo_checker.gemspec
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{seo_checker}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Richard Huang"]
|
12
|
+
s.date = %q{2010-03-04}
|
13
|
+
s.description = %q{seo_checker check your website if it is seo.}
|
14
|
+
s.email = %q{flyerhzm@gmail.com}
|
15
|
+
s.executables = ["seo_checker", "seo_checker"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"bin/seo_checker",
|
24
|
+
"lib/seo_checker.rb",
|
25
|
+
"seo_checker.gemspec"
|
26
|
+
]
|
27
|
+
s.homepage = %q{http://github.com/flyerhzm/seo_checker}
|
28
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
29
|
+
s.require_paths = ["lib"]
|
30
|
+
s.rubygems_version = %q{1.3.6}
|
31
|
+
s.summary = %q{seo_checker check your website if it is seo.}
|
32
|
+
s.test_files = [
|
33
|
+
"examples/bad_seo/app/controllers/application_controller.rb",
|
34
|
+
"examples/bad_seo/app/controllers/posts_controller.rb",
|
35
|
+
"examples/bad_seo/app/helpers/application_helper.rb",
|
36
|
+
"examples/bad_seo/app/helpers/posts_helper.rb",
|
37
|
+
"examples/bad_seo/app/models/post.rb",
|
38
|
+
"examples/bad_seo/config/boot.rb",
|
39
|
+
"examples/bad_seo/config/environment.rb",
|
40
|
+
"examples/bad_seo/config/environments/development.rb",
|
41
|
+
"examples/bad_seo/config/environments/production.rb",
|
42
|
+
"examples/bad_seo/config/initializers/backtrace_silencers.rb",
|
43
|
+
"examples/bad_seo/config/initializers/inflections.rb",
|
44
|
+
"examples/bad_seo/config/initializers/mime_types.rb",
|
45
|
+
"examples/bad_seo/config/initializers/new_rails_defaults.rb",
|
46
|
+
"examples/bad_seo/config/initializers/session_store.rb",
|
47
|
+
"examples/bad_seo/config/routes.rb",
|
48
|
+
"examples/bad_seo/db/migrate/20100228140057_create_posts.rb",
|
49
|
+
"examples/bad_seo/db/schema.rb",
|
50
|
+
"examples/bad_seo/db/seeds.rb",
|
51
|
+
"examples/bad_seo/test/functional/posts_controller_test.rb",
|
52
|
+
"examples/bad_seo/test/performance/browsing_test.rb",
|
53
|
+
"examples/bad_seo/test/test_helper.rb",
|
54
|
+
"examples/bad_seo/test/unit/helpers/posts_helper_test.rb",
|
55
|
+
"examples/bad_seo/test/unit/post_test.rb"
|
56
|
+
]
|
57
|
+
|
58
|
+
if s.respond_to? :specification_version then
|
59
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
|
+
s.specification_version = 3
|
61
|
+
|
62
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
63
|
+
else
|
64
|
+
end
|
65
|
+
else
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seo_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Richard Huang
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-04 00:00:00 +08:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -28,6 +33,7 @@ files:
|
|
28
33
|
- VERSION
|
29
34
|
- bin/seo_checker
|
30
35
|
- lib/seo_checker.rb
|
36
|
+
- seo_checker.gemspec
|
31
37
|
has_rdoc: true
|
32
38
|
homepage: http://github.com/flyerhzm/seo_checker
|
33
39
|
licenses: []
|
@@ -41,42 +47,44 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
47
|
requirements:
|
42
48
|
- - ">="
|
43
49
|
- !ruby/object:Gem::Version
|
50
|
+
segments:
|
51
|
+
- 0
|
44
52
|
version: "0"
|
45
|
-
version:
|
46
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
54
|
requirements:
|
48
55
|
- - ">="
|
49
56
|
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
50
59
|
version: "0"
|
51
|
-
version:
|
52
60
|
requirements: []
|
53
61
|
|
54
62
|
rubyforge_project:
|
55
|
-
rubygems_version: 1.3.
|
63
|
+
rubygems_version: 1.3.6
|
56
64
|
signing_key:
|
57
65
|
specification_version: 3
|
58
66
|
summary: seo_checker check your website if it is seo.
|
59
67
|
test_files:
|
60
|
-
- examples/bad_seo/
|
68
|
+
- examples/bad_seo/app/controllers/application_controller.rb
|
69
|
+
- examples/bad_seo/app/controllers/posts_controller.rb
|
70
|
+
- examples/bad_seo/app/helpers/application_helper.rb
|
71
|
+
- examples/bad_seo/app/helpers/posts_helper.rb
|
72
|
+
- examples/bad_seo/app/models/post.rb
|
73
|
+
- examples/bad_seo/config/boot.rb
|
74
|
+
- examples/bad_seo/config/environment.rb
|
75
|
+
- examples/bad_seo/config/environments/development.rb
|
76
|
+
- examples/bad_seo/config/environments/production.rb
|
61
77
|
- examples/bad_seo/config/initializers/backtrace_silencers.rb
|
62
|
-
- examples/bad_seo/config/initializers/new_rails_defaults.rb
|
63
|
-
- examples/bad_seo/config/initializers/session_store.rb
|
64
78
|
- examples/bad_seo/config/initializers/inflections.rb
|
65
79
|
- examples/bad_seo/config/initializers/mime_types.rb
|
66
|
-
- examples/bad_seo/config/
|
67
|
-
- examples/bad_seo/config/
|
68
|
-
- examples/bad_seo/config/
|
69
|
-
- examples/bad_seo/
|
70
|
-
- examples/bad_seo/
|
71
|
-
- examples/bad_seo/
|
80
|
+
- examples/bad_seo/config/initializers/new_rails_defaults.rb
|
81
|
+
- examples/bad_seo/config/initializers/session_store.rb
|
82
|
+
- examples/bad_seo/config/routes.rb
|
83
|
+
- examples/bad_seo/db/migrate/20100228140057_create_posts.rb
|
84
|
+
- examples/bad_seo/db/schema.rb
|
85
|
+
- examples/bad_seo/db/seeds.rb
|
72
86
|
- examples/bad_seo/test/functional/posts_controller_test.rb
|
87
|
+
- examples/bad_seo/test/performance/browsing_test.rb
|
88
|
+
- examples/bad_seo/test/test_helper.rb
|
73
89
|
- examples/bad_seo/test/unit/helpers/posts_helper_test.rb
|
74
90
|
- examples/bad_seo/test/unit/post_test.rb
|
75
|
-
- examples/bad_seo/db/migrate/20100228140057_create_posts.rb
|
76
|
-
- examples/bad_seo/db/seeds.rb
|
77
|
-
- examples/bad_seo/db/schema.rb
|
78
|
-
- examples/bad_seo/app/helpers/application_helper.rb
|
79
|
-
- examples/bad_seo/app/helpers/posts_helper.rb
|
80
|
-
- examples/bad_seo/app/models/post.rb
|
81
|
-
- examples/bad_seo/app/controllers/application_controller.rb
|
82
|
-
- examples/bad_seo/app/controllers/posts_controller.rb
|