facebook-scraper
facebook-scraper copied to clipboard
Your request couldn't be processed
I'm using the latest code from the master branch and getting the following error. I've also included the code to reproduce this.
Here's my error:
sys:1: UserWarning: A low page limit (<=2) might return no results, try increasing the limit
Traceback (most recent call last):
File "/mnt/storage/Dropbox/Apps/Instamemes/instameme.py", line 35, in <module>
for post in get_posts(pageID, pages=1, cookies='/mnt/storage/Dropbox/Apps/Instamemes/cookies.txt'):
File "/home/tim/.local/lib/python3.9/site-packages/facebook_scraper/facebook_scraper.py", line 1114, in _generic_get_posts
for i, page in zip(counter, iter_pages_fn()):
File "/home/tim/.local/lib/python3.9/site-packages/facebook_scraper/page_iterators.py", line 87, in generic_iter_pages
response = request_fn(next_url)
File "/home/tim/.local/lib/python3.9/site-packages/facebook_scraper/facebook_scraper.py", line 927, in get
raise exceptions.UnexpectedResponse("Your request couldn't be processed")
facebook_scraper.exceptions.UnexpectedResponse: Your request couldn't be processed
And here is my code:
import json
import time
from facebook_scraper import get_posts, set_user_agent
set_user_agent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36")
pages = [
'205332729555617'
,'195392310760'
]
for pageID in pages:
for post in get_posts(pageID, pages=1, cookies='/mnt/storage/Dropbox/Apps/Instamemes/cookies.txt'):
print(json.dumps(post, indent=4, sort_keys=True, default=str))
# avoid getting banned
time.sleep( 2 )
Any ideas?
Thanks!
Try without set_user_agent and/or import json.
import time from facebook_scraper import get_posts, set_user_agent pages = [ '205332729555617' ,'195392310760' ] for pageID in pages: for post in get_posts(pageID, pages=1, cookies='/mnt/storage/Dropbox/Apps/Instamemes/cookies.txt'): #You can print values like this
print('POST_ID: ' + str(post['post_id'])) print('URL: ' + str(post['post_url'])) print('LIKES: ' + postlikes) print('LINK: ' + str(post['link'])) time.sleep( 2 )
Thanks @lgjluis - Unfortunately it's not printing anything. I'm just getting the following:
/home/tim/.local/lib/python3.10/site-packages/facebook_scraper/facebook_scraper.py:912: UserWarning: Facebook says 'Unsupported Browser'
warnings.warn(f"Facebook says 'Unsupported Browser'")
sys:1: UserWarning: A low page limit (<=2) might return no results, try increasing the limit
@lgjluis - I'd be happy to send you my code but already provided it. I'd just be sending you what I pasted up above. And the error I just posted was what I got after running the code you provided. The only thing I haven't posted is my cookies file.
see #858 the fix that did it for me was installing version 0.2.59: "pip install facebook-scraper==0.2.59"
@TRStrange Does my code work for you? Because I tried 0.2.59 and I'm getting the same issue.
I updated my cookie.txt file as Well, but I have a slightly different configuration than you (no user agent setup)