minimaxir/facebook-page-post-scraper

HTTP Error 400: Bad Request

dbsbookg opened this issue · 10 comments

I have registered my facebook developer account and get my app id and app secret. I have a Facebook page to scrape, and I fill in my app id, app secret and the page id.

But I get the following error:

Scraping xx Facebook Page: 2018-06-08 18:18:57.668779

HTTP Error 400: Bad Request

Any idea?

I had this error when on fb developper > Settings > Advanced : "Native or desktop app?" was checked. Thus, if it's checked, uncheck it and it should work.

Having the same issue, and trying the above didn't work.

As stated in #104

Try:

mw0000 commented on Apr 17

the code still works, but you need to make some changes

log in to fb
go to https://developers.facebook.com/tools/explorer/
copy the access token value
edit a *.py file you want use in your project (e.g. get_fb_posts_fb_page.py):
comment a line with access_token = app_id + "|" + app_secret
define new token value:
access_token = "YOUR TOKEN VALUE"

save & run - it should work now
the token can expire - so in a few days when you want to use the script again please regenerate token and paste a new value into the code

@kelvintiger I tried it last week it didn't work, but try it now and it looks working!
However I have the following UnicodeEncodeError now:

UnicodeEncodeError Traceback (most recent call last)
in ()
173
174 if name == 'main':
--> 175 scrapeFacebookPageFeedStatus(page_id, access_token, since_date, until_date)

in scrapeFacebookPageFeedStatus(page_id, access_token, since_date, until_date)
155 # calculate thankful/pride through algebra
156 num_special = status_data[6] - sum(reactions_data)
--> 157 w.writerow(status_data + reactions_data + (num_special,))
158
159 num_processed += 1

UnicodeEncodeError: 'cp950' codec can't encode character '\U0001f525' in position 39: illegal multibyte sequence

Same problem, ERROR 400 issue. @mw0000 solution helped when i was facing 403 error. For 400, it doesnt help.

@dbsbookg @akhisreelibra What pages are you guys trying to scrape? I can try on my end

@kelvintiger im trying to make a corpus related to automobiles. Thus, i was trying to scrape the BMW page in facebook within a months interval.

I am also experiencing the same problem. I have tried the @mw0000 solution and the app id / app secret method, and both give me the same "HTTP Error 400: Bad Request" message

Have you tried looking up that status? E.g. just pasting the status id after the url ("https://www.facebook.com/")? Maybe this status was deleted. This happens for me occassionally, too, however, I treat this as an exception because the statuses were deleted in my case.

Another problem could be, that your app was not reviewed by Facebook yet. If you paste your final url (the one that is being requested by Request(url)) into the browser it might tell you that:

(#10) To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook. To submit this 'Page Public Content Access' feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review.

In this case you need to consider the review procedure of Facebook before requesting anything else.

Works perfectly when I have the admin permission of a page. Not working for any random page