tlyu0419 / facebook_crawler

MIT License
277 stars 68 forks source link

Error in _get_posts() #33

Closed Wen-Chu closed 1 year ago

Wen-Chu commented 1 year ago

I encountered an error while implementing _getposts(). It was working fine previously, but now I'm receiving the following error message:

When calling the Crawl_PagePosts method and executing _getposts(headers, identifier, entryPoint, docid, cursor) in main.py, the response obtained from resp is:

{"data":{"node":null},"errors":[{"message":"A server error missing_required_variable_value occurred. Check server logs for details.","severity":"WARNING"}],"extensions":{"is_final":true}}

Could you please advise on how to resolve this issue? Thank you.

hari56 commented 1 year ago

You have to change the request send towards the api endpoint, and also some other things regarding parsing of the particular fields involved. In order to be able to get a valid response back you have to change variables dictionary:

variables = { "count": 3, "cursor": cursor, "feedLocation": "TIMELINE", "privacySelectorRenderLocation": "COMET_STREAM", "renderLocation": "timeline", "scale": 1, "id": identifier }

    data = {
        "variables": json.dumps(variables),
        "doc_id": docid}

    resp = requests.post(url='https://www.facebook.com/api/graphql/',
                         data=data,
                         headers=headers)
Wen-Chu commented 1 year ago

Thanks for your reply, the problem has been solved!