0

On zhihu, a Chinese Q&A community similar to Quora,I am writing a small program to create a list of users who follow a particular user. On the page showing this information, by scrolling down to the bottom, the browser sends a post request and receives a response in json to extend the followers list.

A snippet of the received json is (copied from firebug):

{"r":0,"msg":["<div class=\"zm-profile-card zm-profile-section-item zg-clear no-hovercard\">\n<div class=\"zg-right\">\n<button data-follow=\"m:button\" data-id=\"f09ebe71535bd89a43dd979c77cf3676\" class=\"zg-btn zg-btn-unfollow zm-rich-follow-btn small nth-0\">\u53d6\u6d88\u5173\u6ce8<\/button>.....

I have little knowledge about json but I am sure that 'msg' contains information about followers.

In my program, I use Python Requests module to send this post request to server.

payload={"method":"next","params":params,"_xsrf":_xsrf}#form data 
response=session.post('http://www.zhihu.com/node/ProfileFollowersListV2',data=payload,headers=header)

response has a status code 200, but response.json() returns:

{u'msg': [], u'r': 0}

where the 'msg' is empty. Can anyone help me with this?

3
  • You're sure it's POST and not GET that the browser is doing? Commented Jan 21, 2015 at 6:36
  • Looks like you should be registered and logged in to view someone's followers. Right? Commented Jan 21, 2015 at 6:37
  • thanks for the comments. I am sure it's POST request as I saw it in firebug. Commented Jan 21, 2015 at 14:22

1 Answer 1

1

I encountered this very problem when I tried to get the content in the returned json file. To solve this, you just need to adjust one thing.

payload={"method":"next","params":params,"_xsrf":_xsrf}

Notice the params. You didn't show us what exactly it was. Since you and I have the same question, I'd assume that your params looks like this,

params = json.dumps({"offset":20,"order_by":"created","hash_id":"blablabla"})

Here is the big one. Your value of "offset" must be an integer, 20 in this case, but definitely not a string, say something like "20". It's really hard to tell what goes wrong when every element is double quoted.

Remember,the value of "offset" must be an integer!

"offset":20
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.