Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40fc648

Browse files
committed
Fix for Issue #56 (Google has changed few things for retrieving PR)
1 parent 27fdccc commit 40fc648

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

extra/pagerank/pagerank.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,30 @@
77
# this version was adapted from http://www.djangosnippets.org/snippets/221/
88
# by Corey Goldberg - 2010
99
#
10+
# important update (http://www.seroundtable.com/google-pagerank-change-14132.html)
11+
# by Miroslav Stampar - 2012
12+
#
1013
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
1114

1215
import urllib
1316

1417
def get_pagerank(url):
15-
hsh = check_hash(hash_url(url))
16-
gurl = 'http://www.google.com/search?client=navclient-auto&features=Rank:&q=info:%s&ch=%s' % (urllib.quote(url), hsh)
18+
_ = 'http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank&ch=%s&q=info:%s' % (check_hash(hash_url(url)), urllib.quote(url))
1719
try:
18-
f = urllib.urlopen(gurl)
20+
f = urllib.urlopen(_)
1921
rank = f.read().strip()[9:]
2022
except Exception:
2123
rank = 'N/A'
22-
if rank == '':
23-
rank = '0'
24+
else:
25+
rank = '0' if not rank or not rank.isdigit() else rank
2426
return rank
2527

2628
def int_str(string_, integer, factor):
2729
for i in xrange(len(string_)) :
2830
integer *= factor
2931
integer &= 0xFFFFFFFF
3032
integer += ord(string_[i])
33+
3134
return integer
3235

3336
def hash_url(string_):

lib/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ def parseTargetUrl():
10671067
if urlSplit[3]:
10681068
conf.parameters[PLACE.GET] = urldecode(urlSplit[3]) if urlSplit[3] and urlencode(DEFAULT_GET_POST_DELIMITER, None) not in urlSplit[3] else urlSplit[3]
10691069

1070-
conf.url = "%s://%s:%d%s" % (conf.scheme, ("[%s]" % conf.hostname) if conf.ipv6 else conf.hostname, conf.port, conf.path)
1070+
conf.url = getUnicode("%s://%s:%d%s" % (conf.scheme, ("[%s]" % conf.hostname) if conf.ipv6 else conf.hostname, conf.port, conf.path))
10711071
conf.url = conf.url.replace(URI_QUESTION_MARKER, '?')
10721072

10731073
if not conf.referer and intersect(REFERER_ALIASES, conf.testParameter, True):

0 commit comments

Comments
 (0)