Python API returning 5.0 and errors in test_postrank.py
Python API? I think there are a few issues. Firstly, in the test_postrank.py file, the script contains a parameter called "urls" ... which doesn't work, it only accepts "url" as a list.
Secondly, if I send one URL in the "url" param I always get 5.0 back as a postrank, whereas if I prepend the list with any other URL the other value returned starts to vary.
Am I doing something wrong, all I want is to enter a URL and get a number out? I've just noticed that "thematic" only compares URLs... Can I do what I want?
thanks tom@everythingability.com
I
Secondly, if I send one URL in the "url" param I always get 5.0 back as a postrank, whereas if I prepend the list with any other URL the other value returned starts to vary.
Am I doing something wrong, all I want is to enter a URL and get a number out? I've just noticed that "thematic" only compares URLs... Can I do what I want?
thanks tom@everythingability.com
I
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?Tom, the behavior you're seeing with one URL always returning the score of 5.0 is as expected. What you're requesting is "Thematic PostRank" which means the stories will be ranked against each other for the list you've provided. Of course, the edge case is 1 url in this case. Since it will be ranked against itself, it will always be perfectly average (or 5.0).
If you're looking to rank a story or a collection of stories with respect to some feeds, you should be providing a collection of feed identifiers as well - this is what we call 'Feed-based PostRank'.
More on Feed-based vs Thematic:
http://www.postrank.com/postrank#feed...
Take a look at the code examples here:
http://www.postrank.com/developers/ap...
-
Inappropriate?I don't quite get this... And I have read the documentation in detail... but I'm a bit dense....
If I do a "feed-based" query, I assume I first get the feed_id, then make a query using that... right? Could I just use the "base site url" to compare a post to its own root?
If I do a thematic query, I pass in (at least) 2 URLs to compare and get a number for each... What does this do, are they compared by content or just by other things (like comments, diggs, etc)... Could I maybe use an "exemplar post" and see how the posts I want to compare fare against it?
For example, will this work?
######################################################
from urlparse import urlsplit
def get_postrank( url ):
# GET THE FEED ID
pr = PostRank( )
r = pr('feed_id', appkey='theotherblog.com', format='json', url=url)
if r == [None, None]:
#feed not found!
return 0.0
feed_id= r[PROCESSED]['feed_id']
#NOW GET THE PAGE'S RANK RELATIVE TO ITS ROOT
p = PostRank( )
items = urlsplit( url)
site_url = "http://" + items[1] # Make a URL that points at the root of the site (assuming the URL isn't)
f = p('postrank', appkey='theotherblog.com', format='json', url=[url, site_url], feed_id=[feed_id])
postrank_num = float( f[1][url]['postrank'] )
return postrank_num
######################################################
I’m befuddled, peckish
-
Inappropriate?Tom you're on the right track. If you want to use 'Feed-based' postrank, then you do need to retrieve the feed_id first and then pass it into your postrank call.
The way feed-based postrank works is: each story is ranked against the historical average performance of the posts preceding it. So, for example, if you have a post at time t2, and another post at time t5, when you do feed-based postrank, the score for t2 will be with respect to posts published prior to t2. Same pattern for t5.
The alternative way is to use 'thematic postrank', in which case the ranking will be relative all of the URL's you've passed in.
Hope that makes sense.
Loading Profile...




EMPLOYEE