Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 160 lines (107 sloc) 5.825 kb
d3cf1ea @blatyo Added backlink lookups.
authored
1 # PageRankr
1482bcf @blatyo Initial commit to page_rankr.
authored
2
22d0e59 @blatyo Changed readme to markdown. Added TODO list.
authored
3 Provides an easy way to retrieve Google Page Rank, Alexa Rank, and backlink counts.
1482bcf @blatyo Initial commit to page_rankr.
authored
4
9d37eb9 @blatyo Updated doc to point to is_it_popular as an ecample app.
authored
5 Check out a little [web app][1] I wrote up that uses it or look at the [source][2].
6
7 [1]: http://isitpopular.heroku.com
b4ac8cb @blatyo Added iteration labs as contributor
authored
8 [2]: https://github.com/blatyo/is_it_popular
9d37eb9 @blatyo Updated doc to point to is_it_popular as an ecample app.
authored
9
c1ecbed @blatyo Fixed google backlinks lookup, since they've updated the page. Change…
authored
10 ## Get it!
11
12 gem install PageRankr
0890ec2 @blatyo Updated readme
authored
13
c1ecbed @blatyo Fixed google backlinks lookup, since they've updated the page. Change…
authored
14 ## Use it!
15
16 require 'page_rankr'
d3cf1ea @blatyo Added backlink lookups.
authored
17
18 ### Backlinks
19
ae57d4e @blatyo Updated docs for version 2 release.
authored
20 Backlinks are the result of doing a search with a query like "link:www.google.com". The number of returned results indicates how many sites point to that url. If a site is not tracked then `nil` is returned.
1e2fb99 @blatyo docs are the bane of my existence
authored
21
c1ecbed @blatyo Fixed google backlinks lookup, since they've updated the page. Change…
authored
22 PageRankr.backlinks('www.google.com', :google, :bing) #=> {:google=>161000, :bing=>208000000}
23 PageRankr.backlinks('www.google.com', :yahoo) #=> {:yahoo=>256300062}
0890ec2 @blatyo Updated readme
authored
24
9a5183e @blatyo Added singular aliases and made shortcut for all search engines for r…
authored
25 If you don't specify a search engine, then all of them are used.
26
27 # this
0890ec2 @blatyo Updated readme
authored
28 PageRankr.backlinks('www.google.com')
ae57d4e @blatyo Updated docs for version 2 release.
authored
29 #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :alexa=>727036}
0890ec2 @blatyo Updated readme
authored
30
9a5183e @blatyo Added singular aliases and made shortcut for all search engines for r…
authored
31 # is equivalent to
ae57d4e @blatyo Updated docs for version 2 release.
authored
32 PageRankr.backlinks('www.google.com', :google, :bing, :yahoo, :alexa)
33 #=> {:google=>23000, :bing=>215000000, :yahoo=>250522337, :alexa=>727036}
1e2fb99 @blatyo docs are the bane of my existence
authored
34
9a5183e @blatyo Added singular aliases and made shortcut for all search engines for r…
authored
35 You can also use the alias `backlink` instead of `backlinks`.
288eaa4 @blatyo Made it easier to get list of supported trackers and refactored.
authored
36
ae57d4e @blatyo Updated docs for version 2 release.
authored
37 Valid search engines are: `:google, :bing, :yahoo, :alexa` (altavista and alltheweb now redirect to yahoo). To get this list you can do:
38
39 PageRankr.backlink_trackers #=> [:alexa, :bing, :google, :yahoo]
d3cf1ea @blatyo Added backlink lookups.
authored
40
dd14f3a @blatyo Convert Test::Unit to Rspec. Update docs.
authored
41 ### Indexes
42
ae57d4e @blatyo Updated docs for version 2 release.
authored
43 Indexes are the result of doing a search with a query like "site:www.google.com". The number of returned results indicates how many pages of a domain are indexed by a particular search engine. If the site is not indexed `nil` is returned.
dd14f3a @blatyo Convert Test::Unit to Rspec. Update docs.
authored
44
45 PageRankr.indexes('www.google.com', :google) #=> {:google=>4860000}
46 PageRankr.indexes('www.google.com', :bing) #=> {:bing=>2120000}
47
48 If you don't specify a search engine, then all of them are used.
49
50 # this
51 PageRankr.indexes('www.google.com')
52 #=> {:bing=>2120000, :google=>4860000}
53
54 # is equivalent to
55 PageRankr.indexes('www.google.com', :google, :bing)
56 #=> {:bing=>2120000, :google=>4860000}
57
58 You can also use the alias `index` instead of `indexes`.
ae57d4e @blatyo Updated docs for version 2 release.
authored
59
dd14f3a @blatyo Convert Test::Unit to Rspec. Update docs.
authored
60 Valid search engines are: `:google, :bing`. To get this list you can do:
61
ae57d4e @blatyo Updated docs for version 2 release.
authored
62 PageRankr.index_trackers #=> [:bing, :google]
dd14f3a @blatyo Convert Test::Unit to Rspec. Update docs.
authored
63
9a01744 @blatyo Added alexa and google ranks.
authored
64 ### Ranks
c1ecbed @blatyo Fixed google backlinks lookup, since they've updated the page. Change…
authored
65
ae57d4e @blatyo Updated docs for version 2 release.
authored
66 Ranks are ratings assigned to specify how popular a site is. The most famous example of this is the google page rank.
67
68 PageRankr.ranks('www.google.com', :google) #=> {:google=>10}
7b46b77 @blatyo Update docs
authored
69
ae57d4e @blatyo Updated docs for version 2 release.
authored
70 If you don't specify a rank provider, then all of them are used.
71
72 PageRankr.ranks('www.google.com', :alexa_us, :alexa_global, :compete, :google)
73 #=> {:alexa_us=>1, :alexa_global=>1, :google=>10, :compete=>1}
0890ec2 @blatyo Updated readme
authored
74
9a5183e @blatyo Added singular aliases and made shortcut for all search engines for r…
authored
75 # this also gives the same result
ae57d4e @blatyo Updated docs for version 2 release.
authored
76 PageRankr.ranks('www.google.com')
77 #=> {:alexa_us=>1, :alexa_global=>1, :google=>10, :compete=>1}
9a01744 @blatyo Added alexa and google ranks.
authored
78
9a5183e @blatyo Added singular aliases and made shortcut for all search engines for r…
authored
79 You can also use the alias `rank` instead of `ranks`.
288eaa4 @blatyo Made it easier to get list of supported trackers and refactored.
authored
80
ae57d4e @blatyo Updated docs for version 2 release.
authored
81 Valid rank trackers are: `:alexa_us, :alexa_global, :compete, :google`. To get this you can do:
82
83 PageRankr.rank_trackers #=> [:alexa_global, :alexa_us, :compete, :google]
288eaa4 @blatyo Made it easier to get list of supported trackers and refactored.
authored
84
ae57d4e @blatyo Updated docs for version 2 release.
authored
85 Alexa and Compete ranks are descending where 1 is the most popular. Google page ranks are in the range 0-10 where 10 is the most popular. If a site is unindexed then the rank will be nil.
9a01744 @blatyo Added alexa and google ranks.
authored
86
eb9d015 @blatyo Huge refactoring. Now its simpler to extend and provide temporary fixes.
authored
87 ## Fix it!
88
89 If you ever find something is broken it should now be much easier to fix it with version >= 1.3.0. For example, if the xpath used to lookup a backlink is broken, just override the method for that class to provide the correct xpath.
90
91 module PageRankr
ae57d4e @blatyo Updated docs for version 2 release.
authored
92 class Backlinks
93 class Bing
eb9d015 @blatyo Huge refactoring. Now its simpler to extend and provide temporary fixes.
authored
94 def xpath
ae57d4e @blatyo Updated docs for version 2 release.
authored
95 "//my/new/awesome/@xpath"
eb9d015 @blatyo Huge refactoring. Now its simpler to extend and provide temporary fixes.
authored
96 end
97 end
98 end
99 end
100
101 ## Extend it!
102
ae57d4e @blatyo Updated docs for version 2 release.
authored
103 If you ever come across a site that provides a rank or backlinks you can hook that class up to automatically be use with PageRankr. PageRankr does this by looking up all the classes namespaced under Backlinks, Indexes, and Ranks.
eb9d015 @blatyo Huge refactoring. Now its simpler to extend and provide temporary fixes.
authored
104
105 module PageRankr
ae57d4e @blatyo Updated docs for version 2 release.
authored
106 class Backlinks
107 class Foo
108 include Backlink
109
110 def request
111 @request ||= Typhoeus::Request.new("http://example.com/",
112 :params => {:q => @site.to_s})
eb9d015 @blatyo Huge refactoring. Now its simpler to extend and provide temporary fixes.
authored
113 end
0890ec2 @blatyo Updated readme
authored
114
eb9d015 @blatyo Huge refactoring. Now its simpler to extend and provide temporary fixes.
authored
115 def xpath
116 "//backlinks/text()"
117 end
0890ec2 @blatyo Updated readme
authored
118
eb9d015 @blatyo Huge refactoring. Now its simpler to extend and provide temporary fixes.
authored
119 def clean(backlink_count)
120 #do some of my own cleaning
121 super(backlink_count) # strips letters, commas, and a few other nasty things and converts it to an integer
122 end
123 end
124 end
125 end
0890ec2 @blatyo Updated readme
authored
126
127 Then, just make sure you require the class and PageRankr and whenever you call PageRankr.backlinks it'll be able to use your class.
9a01744 @blatyo Added alexa and google ranks.
authored
128
22d0e59 @blatyo Changed readme to markdown. Added TODO list.
authored
129 ## Note on Patches/Pull Requests
0890ec2 @blatyo Updated readme
authored
130
1482bcf @blatyo Initial commit to page_rankr.
authored
131 * Fork the project.
132 * Make your feature addition or bug fix.
133 * Add tests for it. This is important so I don't break it in a
134 future version unintentionally.
135 * Commit, do not mess with rakefile, version, or history.
136 (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
137 * Send me a pull request. Bonus points for topic branches.
138
ae57d4e @blatyo Updated docs for version 2 release.
authored
139 ## TODO Version 3
1ca1c41 @blatyo Added contributor
authored
140 * Use API's where possible
0890ec2 @blatyo Updated readme
authored
141 * Configuration
dd14f3a @blatyo Convert Test::Unit to Rspec. Update docs.
authored
142 * Optionally use API keys
ae57d4e @blatyo Updated docs for version 2 release.
authored
143 * Maybe allow API key cycling to get around query limits
144 * Google search API is deprecated
1ca1c41 @blatyo Added contributor
authored
145
146 ## Contributors
b4ac8cb @blatyo Added iteration labs as contributor
authored
147 * [Druwerd](https://github.com/Druwerd) - Use Google Search API instead of scraping.
ae57d4e @blatyo Updated docs for version 2 release.
authored
148 * [Iteration Labs, LLC](https://github.com/iterationlabs) - Compete rank tracker and domain indexes.
9a01744 @blatyo Added alexa and google ranks.
authored
149
150 ## Shout Out
151 Gotta give credit where credits due!
bf0297b @blatyo FORMATING!!!
authored
152
b4ac8cb @blatyo Added iteration labs as contributor
authored
153 Original inspiration from:
154 * [PageRankSharp](https://github.com/alexmipego/PageRankSharp)
155 * [Google Page Range Lookup/](http://snipplr.com/view/18329/google-page-range-lookup/)
156 * [AJAX PR Checker](http://www.sitetoolcenter.com/free-website-scripts/ajax-pr-checker.php)
1482bcf @blatyo Initial commit to page_rankr.
authored
157
22d0e59 @blatyo Changed readme to markdown. Added TODO list.
authored
158 ## Copyright
159
9a01744 @blatyo Added alexa and google ranks.
authored
160 Copyright (c) 2010 Allen Madsen. See LICENSE for details.
Something went wrong with that request. Please try again.