Class: GooglePageRank
- Inherits:
-
Object
- Object
- GooglePageRank
- Defined in:
- lib/googlepagerank.rb
Constant Summary collapse
- M =
modulo for unsigned int 32bit(4byte)
0x100000000
Class Method Summary collapse
-
.get(url = "http://sample/index.html", port = 80, proxy = nil, proxy_port = nil) ⇒ Object
Calculates the PageRank for the given url New algorithm version (16 july 2007).
-
.get0(url = "http://sample/index.html", port = 80, proxy = nil, proxy_port = nil) ⇒ Object
Calculates the PageRank for the given url ATENTION: Old version, use the GooglePageRak.get() instead .
Class Method Details
.get(url = "http://sample/index.html", port = 80, proxy = nil, proxy_port = nil) ⇒ Object
Calculates the PageRank for the given url New algorithm version (16 july 2007)
:call-seq: GooglePageRank.get(“url”,,[proxy_url],) -> Fixnum
If an error ocurrs with the connection or the domain isn’t indexed returns -1
Parameters
- url<String>
- port<Fixnum>
- proxy<String>
- proxy_port<Fixnum>
- port<Fixnum>
-
Returns
- Fixnum
-
The PageRank for the given url.
Examples
GooglePageRank.get("www.mabishu.com") # => 4 GooglePageRank.get("www.mabishu.com", 80) # => 4 GooglePageRank.get("www.mabishu.com", 80, "http://proxy.example.com", 8080) # => 4
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/googlepagerank.rb', line 72 def self.get(url="http://sample/index.html",port=80,proxy=nil,proxy_port=nil) # get Google PageRank # 2007.07.10 ch = checkSum(url); # printf("CheckSUM: 6%u\n", ch); ###### format changed #g_path=sprintf("/search?client=navclient-auto&failedip=216.239.51.102;821&ch=6%u&q=info:%s", ch, url); g_path=sprintf("/search?client=navclient-auto&features=Rank&failedip=216.239.51.102;821&q=info:%s&ch=6%u", url, ch); p="" # rank # printf("%s\n",g_path) # http://www.google.co.jp/search?client=navclient-auto&ch=63055969557&features=Rank&q=info:http://www.hyperposition.com/se3blog/ # http://www.google.co.jp/search?client=navclient-auto&features=Rank&q=info:http://www.hyperposition.com/&ch=6768349016 g_server="toolbarqueries.google.com" # toolbarqueries.google.co.jp Net::HTTP::new(g_server, port, proxy, proxy_port).get(g_path){|line| # printf("%s\n", line) ###### format changed pos=line.index("Rank_1:1:") # format: Rank_1:1:4 if( pos != nil) then p=(line[pos+9,2]).to_i; break; end; } if (p.size>0) then return p.to_i; else return -1; end end |
.get0(url = "http://sample/index.html", port = 80, proxy = nil, proxy_port = nil) ⇒ Object
Calculates the PageRank for the given url ATENTION: Old version, use the GooglePageRak.get() instead
:call-seq: GooglePageRank.get0(“url”,,[proxy_url],) -> Fixnum
If an error ocurrs with the connection or the domain isn’t indexed returns -1
Parameters
- url<String>
- port<Fixnum>
- proxy<String>
- proxy_port<Fixnum>
- port<Fixnum>
-
Returns
- Fixnum
-
The PageRank for the given url.
Examples
GooglePageRank.get0("www.mabishu.com") # => 4 GooglePageRank.get0("www.mabishu.com", 80) # => 4 GooglePageRank.get0("www.mabishu.com", 80, "http://proxy.example.com", 8080) # => 4
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/googlepagerank.rb', line 29 def self.get0(url="http://sample/index.html",port=80,proxy=nil,proxy_port=nil) # get Google PageRank # old version ch = checkSum(url); # printf("CheckSUM: 6%u\n", ch); g_path=sprintf("/search?client=navclient-auto&failedip=216.239.51.102;821&ch=6%u&q=info:%s", ch, url); p="" # rank ## printf("%s\n",g_path) # http://www.google.co.jp/search?client=navclient-auto&ch=63055969557&features=Rank&q=info:http://www.hyperposition.com/se3blog/ # http://www.google.co.jp/search?client=navclient-auto&features=Rank&q=info:http://www.hyperposition.com/&ch=6768349016 g_server="toolbarqueries.google.com" # toolbarqueries.google.co.jp #g_server="www.google.co.jp" Net::HTTP::new(g_server, port, proxy, proxy_port).get(g_path){|line| printf("%s\n", line) pos=line.index("<RK>") # format: <RK>(rank)</RK> if( pos != nil) then p=(line[pos+4,2]).to_i; break; end; } if (p.size>0) then return p.to_i; else return -1; end end |