seo_params 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -1
- data/lib/seo_params/alexa.rb +23 -0
- data/lib/seo_params/facebook.rb +22 -0
- data/lib/seo_params/netcraft.rb +74 -0
- data/lib/seo_params/twitter.rb +19 -0
- data/lib/seo_params/version.rb +1 -1
- data/lib/seo_params/yandex.rb +6 -11
- data/lib/seo_params.rb +28 -0
- metadata +6 -2
data/README.md
CHANGED
@@ -33,13 +33,17 @@ Or install it yourself as:
|
|
33
33
|
|
34
34
|
``` ruby
|
35
35
|
SeoParams.all("gihub.com")
|
36
|
-
# => {"pr"=>7, "gp"=>
|
36
|
+
# => {"pr"=>7, "gp"=>42200000, "tic"=>3700, "yap"=>627199, "tweets"=>532, "likes"=>"5,2 т.", "ar"=>276, "dmoz"=>"yes"}
|
37
37
|
```
|
38
38
|
Short description:
|
39
39
|
`pr` - Google PageRank,
|
40
40
|
`gp` - pages in Google index,
|
41
41
|
`tic` - Yandex tIC,
|
42
42
|
`yap` - pages in Yandex index.
|
43
|
+
`tweets` - Twitter tweets
|
44
|
+
`likes` - Facebook likes, on Russian in my case
|
45
|
+
`ar` - Alexa rank
|
46
|
+
`dmoz` - presence in the DMOZ directory
|
43
47
|
|
44
48
|
### Fetch specific SEO parameter
|
45
49
|
|
@@ -72,6 +76,34 @@ To fetch only pages in Google index:
|
|
72
76
|
# => 627119
|
73
77
|
```
|
74
78
|
|
79
|
+
To fetch only tweets
|
80
|
+
|
81
|
+
``` ruby
|
82
|
+
SeoParams.tweets("gihub.com")
|
83
|
+
# => 532
|
84
|
+
```
|
85
|
+
|
86
|
+
To fetch only likes
|
87
|
+
|
88
|
+
``` ruby
|
89
|
+
SeoParams.likes("gihub.com")
|
90
|
+
# => "5,2 т."
|
91
|
+
```
|
92
|
+
|
93
|
+
DMOZ:
|
94
|
+
|
95
|
+
``` ruby
|
96
|
+
SeoParams.dmoz("gihub.com")
|
97
|
+
# => "yes"
|
98
|
+
```
|
99
|
+
|
100
|
+
### Check Netcraft parametrs
|
101
|
+
|
102
|
+
``` ruby
|
103
|
+
SeoParams.netcraft("gihub.com")
|
104
|
+
# => {"ip"=>"207.97.227.239", "siterank"=>9359, "country"=>"US", "nameserver"=>"ns1.p16.dynect.net", "firstseen"=>"August 2011", "dnsadmin"=>"hostmaster@github.com", "domainregistrator"=>"godaddy.com", "reversedns"=>"github.com", "organisation"=>"GitHub, Inc.", "nsorganisation"=>"Dynamic Network Services, Inc., 150 Dow St, Manchester, 03101, United States"}
|
105
|
+
```
|
106
|
+
|
75
107
|
### Check site position in the search for keywords in Google
|
76
108
|
|
77
109
|
The most visited sites - are sites on the first page of a search result the user. That is why it is so important control whether the position of your website for keywords.
|
@@ -118,7 +150,9 @@ Checking the position of keywords in Yandex need only for RuNET, so further desc
|
|
118
150
|
С проверкой позиций в Яндексе всё несколько сложнее.
|
119
151
|
|
120
152
|
Во-первых, Вам необходимо быть зарегестрированным пользователем Яндекса. Сделать это можно по вот этой [ссылке][1].
|
153
|
+
|
121
154
|
Во-вторых, добавить IP-адрес, с которого будут посылаться запросы к сервису Яндекса, на этой [страничке][2]
|
155
|
+
|
122
156
|
В-третьих, скопировать/сохранить `user` и `key` из поля "Ваш адрес для совершения запроса" на страничке в предыдущем пункте. Важно знать, что просто зарегистрированные пользователи могут делать не более 10 запросов в день. Если Вы подтвердите Ваш номер телефона, то сможете делать до 1000 запросов в день. Думаю, для многих этого будет достаточно, а кому и этого мало, тогда следует ознакомиться с информацией на самом сайте, как увеличить данное число.
|
123
157
|
|
124
158
|
В принципе, уже можно пробовать:
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module SeoParams
|
6
|
+
|
7
|
+
class Alexa
|
8
|
+
|
9
|
+
def initialize(url)
|
10
|
+
@url = url
|
11
|
+
@response = Nokogiri::HTML(open("http://xml.alexa.com/data?cli=10&dat=nsa&ver=quirk-searchstatus&url=#{url}"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def rank
|
15
|
+
rank = @response.css("popularity").attr("text").content().to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
def dmoz
|
19
|
+
@response.xpath("//alexa/dmoz").length > 0 ? "yes" : "no"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module SeoParams
|
6
|
+
|
7
|
+
class Facebook
|
8
|
+
|
9
|
+
def initialize(url)
|
10
|
+
@url = url
|
11
|
+
end
|
12
|
+
|
13
|
+
def likes
|
14
|
+
api_url = "http://www.facebook.com/plugins/like.php?layout=button_count&href=#{@url}"
|
15
|
+
response = Nokogiri::HTML(open(api_url))
|
16
|
+
total_likes = response.css("span.pluginCountTextDisconnected")
|
17
|
+
total_likes.text()
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module SeoParams
|
6
|
+
|
7
|
+
class Netcraft
|
8
|
+
|
9
|
+
def initialize(url)
|
10
|
+
@url = url
|
11
|
+
@response = Nokogiri::HTML(open("http://toolbar.netcraft.com/site_report?url=#{url}"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def all
|
15
|
+
|
16
|
+
h = Hash.new
|
17
|
+
h["ip"] = get_ip
|
18
|
+
h["siterank"] = get_siterank == 'unknown' ? 'n/a' : get_siterank.to_i
|
19
|
+
h["country"] = get_country
|
20
|
+
h["nameserver"] = get_nameserver
|
21
|
+
h["firstseen"] = get_firstseen
|
22
|
+
h["dnsadmin"] = get_dnsadmin
|
23
|
+
h["domainregistrator"] = get_domainregistrator == 'unknown' ? 'n/a' : get_domainregistrator
|
24
|
+
h["reversedns"] = get_reversedns
|
25
|
+
h["organisation"] = get_organisation == 'unknown' ? 'n/a' : get_organisation
|
26
|
+
h["nsorganisation"] = get_nsorganisation == 'unknown' ? 'n/a' : get_nsorganisation
|
27
|
+
h
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def get_ip
|
34
|
+
@response.xpath("//table/tr")[2].children()[1].text()
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_siterank
|
38
|
+
@response.xpath("//table/tr")[2].children()[4].children().text()
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_country
|
42
|
+
@response.xpath("//table/tr")[3].children()[1].children().children().text().to_s[/\w+/]
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_nameserver
|
46
|
+
@response.xpath("//table/tr")[3].children()[4].children().text()
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_firstseen
|
50
|
+
@response.xpath("//table/tr")[4].children()[1].text()
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_dnsadmin
|
54
|
+
@response.xpath("//table/tr")[4].children()[4].children().text()
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_domainregistrator
|
58
|
+
@response.xpath("//table/tr")[5].children()[1].text()
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_reversedns
|
62
|
+
@response.xpath("//table/tr")[5].children()[4].children().text()
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_organisation
|
66
|
+
@response.xpath("//table/tr")[6].children()[1].text()
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_nsorganisation
|
70
|
+
@response.xpath("//table/tr")[6].children()[4].children().text()
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module SeoParams
|
6
|
+
|
7
|
+
class Twitter
|
8
|
+
def initialize(url)
|
9
|
+
@url = url
|
10
|
+
end
|
11
|
+
|
12
|
+
def tweets
|
13
|
+
api_url = "http://urls.api.twitter.com/1/urls/count.json?url=#{@url}"
|
14
|
+
response = JSON.parse(open(api_url).read)
|
15
|
+
response["count"]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/seo_params/version.rb
CHANGED
data/lib/seo_params/yandex.rb
CHANGED
@@ -20,7 +20,7 @@ module SeoParams
|
|
20
20
|
|
21
21
|
def yandex_pages
|
22
22
|
pages = ask_yandex(@url)
|
23
|
-
(pages.is_a? String) ? (url = pages; pages = ask_yandex(
|
23
|
+
(pages.is_a? String) ? (@url = pages; pages = ask_yandex(pages); ) : pages
|
24
24
|
pages
|
25
25
|
end
|
26
26
|
|
@@ -55,18 +55,13 @@ module SeoParams
|
|
55
55
|
doc = Nokogiri::HTML(open("http://webmaster.yandex.ua/check.xml?hostname=#{url}"))
|
56
56
|
|
57
57
|
if doc.css('div.error-message').length > 0
|
58
|
-
|
59
|
-
|
60
|
-
new_url = doc.css('div.error-message').to_s.scan(url_regexp)[0][0]
|
61
|
-
index = new_url
|
62
|
-
end
|
58
|
+
|
59
|
+
index = doc.css('div.error-message').children().children()[1].text()[0..-3].lstrip
|
63
60
|
|
64
61
|
else
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
index = @pages_in_index[0].to_i
|
69
|
-
end
|
62
|
+
|
63
|
+
index = doc.css('div.header div').text()[/\d+/].to_i
|
64
|
+
|
70
65
|
end
|
71
66
|
|
72
67
|
index
|
data/lib/seo_params.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
require File.expand_path('../seo_params/google', __FILE__)
|
4
4
|
require File.expand_path('../seo_params/yandex', __FILE__)
|
5
|
+
require File.expand_path('../seo_params/alexa', __FILE__)
|
6
|
+
require File.expand_path('../seo_params/facebook', __FILE__)
|
7
|
+
require File.expand_path('../seo_params/netcraft', __FILE__)
|
8
|
+
require File.expand_path('../seo_params/twitter', __FILE__)
|
5
9
|
|
6
10
|
module SeoParams
|
7
11
|
|
@@ -13,6 +17,10 @@ module SeoParams
|
|
13
17
|
h["gp"] = gp(url)
|
14
18
|
h["tic"] = tic(url)
|
15
19
|
h["yap"] = yap(url)
|
20
|
+
h["tweets"] = tweets(url)
|
21
|
+
h["likes"] = likes(url)
|
22
|
+
h["ar"] = ar(url)
|
23
|
+
h["dmoz"] = dmoz(url)
|
16
24
|
h
|
17
25
|
end
|
18
26
|
|
@@ -51,6 +59,26 @@ module SeoParams
|
|
51
59
|
Google.new(url).google_position(options[:hl], options[:cr], keywords, options[:num])
|
52
60
|
end
|
53
61
|
|
62
|
+
def tweets(url)
|
63
|
+
Twitter.new(url).tweets
|
64
|
+
end
|
65
|
+
|
66
|
+
def likes(url)
|
67
|
+
Facebook.new(url).likes
|
68
|
+
end
|
69
|
+
|
70
|
+
def ar(url)
|
71
|
+
Alexa.new(url).rank
|
72
|
+
end
|
73
|
+
|
74
|
+
def dmoz(url)
|
75
|
+
Alexa.new(url).dmoz
|
76
|
+
end
|
77
|
+
|
78
|
+
def netcraft(url)
|
79
|
+
Netcraft.new(url).all
|
80
|
+
end
|
81
|
+
|
54
82
|
end
|
55
83
|
|
56
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seo_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -88,7 +88,11 @@ files:
|
|
88
88
|
- README.md
|
89
89
|
- Rakefile
|
90
90
|
- lib/seo_params.rb
|
91
|
+
- lib/seo_params/alexa.rb
|
92
|
+
- lib/seo_params/facebook.rb
|
91
93
|
- lib/seo_params/google.rb
|
94
|
+
- lib/seo_params/netcraft.rb
|
95
|
+
- lib/seo_params/twitter.rb
|
92
96
|
- lib/seo_params/version.rb
|
93
97
|
- lib/seo_params/yandex.rb
|
94
98
|
- seo_params.gemspec
|