kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.42k stars 631 forks source link

Getting the issue of unsupported browser for facebook #718

Open MussabMehboob opened 2 years ago

MussabMehboob commented 2 years ago

I am attaching an image showing the problem. I am getting this error. Input Code:

from facebook_scraper import * get_group_info("Python Developers Connect",cookies="cookie.txt")

Output:

warnings.warn(f"Facebook says 'Unsupported Browser'") Traceback (most recent call last): File "C:\Users\Mussab\PycharmProjects\Facebook Scraper\main.py", line 2, in get_group_info("Python Developer Connect", cookies="cookie.txt") File "C:\Users\Mussab\PycharmProjects\Facebook Scraper\venv\lib\site-packages\facebook_scraper__init__.py", line 126, in get_group_info return _scraper.get_group_info(group, **kwargs) File "C:\Users\Mussab\PycharmProjects\Facebook Scraper\venv\lib\site-packages\facebook_scraper\facebook_scraper.py", line 665, in get_group_info resp = self.get(url).html File "C:\Users\Mussab\PycharmProjects\Facebook Scraper\venv\lib\site-packages\facebook_scraper\facebook_scraper.py", line 829, in get raise exceptions.UnexpectedResponse("Your request couldn't be processed") facebook_scraper.exceptions.UnexpectedResponse: Your request couldn't be processed

issue
weg38asyy commented 2 years ago

try it, adding a user agent.

from facebook_scraper import *

set_user_agent(
    "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")

This worked for me.

neon-ninja commented 2 years ago

You need to pass the group id, not name. "pythonconnect" instead of "Python Developers Connect"

wgicio commented 2 years ago

facebook-scraper 350448261731413

I am also getting this error message when passing the ID

jpkrop commented 2 years ago

I have the same error now (first time, before all works good). I add the user agent as the post of @weg38asyy but this time I not have error message but I have a new problem, result is not complete (maybe 5%).

Do you know why ?

neon-ninja commented 2 years ago

@wgicio is that the full command?

@jpkrop I wouldn't recommend using that user agent

wgicio commented 2 years ago

@neon-ninja facebook-scraper 350448261731413 --filename 20220410_350448261731413.csv --cookies fbcookie.txt --group --sleep 4 --pages 15 --days-limit 14 --k post_id,text,time,image,images,link,post_url,user_id,username,listing_price,page_id --encoding utf8 --verbose -nm $'We are looking for|massage|im looking for|hello all|hello dear|HAIR COLOUR|hello everybody|hello friends|hi guys|hello guys|hi there|hello there|carpenter|jeep|moving service|we are a couple|i am looking for|Scooter Rental|i\'m looking for|we\'re looking for' -m '081|082|085|086|087|089|628|62 8|62-8|wa.me|whatsapp|Whats App|Dm|Pm|message'

neon-ninja commented 2 years ago

Using that command generates a CSV with 7 rows, so it seems to be working fine for me

neon-ninja commented 2 years ago

Maybe try update to the latest version

Nabeelyousaf commented 2 years ago

Hey i m getting this error C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\facebook_scraper\facebook_scraper.py:841: UserWarning: Facebook says 'Unsupported Browser' warnings.warn(f"Facebook says 'Unsupported Browser'") image

Nabeelyousaf commented 2 years ago

@neon-ninja any solution about it

neon-ninja commented 2 years ago

It's not an error, just a warning. It's safe to ignore

Nabeelyousaf commented 2 years ago

@neon-ninja ok got it hey, can I get Facebook page info?

neon-ninja commented 2 years ago

Yes. get_profile returns a dict. Try print it to console

Nabeelyousaf commented 2 years ago

hey @neon-ninja i m getting this exception in get raise exceptions.LoginRequired( facebook_scraper.exceptions.LoginRequired: A login (cookies) is required to see this page image

neon-ninja commented 2 years ago

Then pass cookies as per the readme

Nabeelyousaf commented 2 years ago

@neon-ninja i m getting new error image

neon-ninja commented 2 years ago

The cookies.txt file needs to be in the same directory as where you run the script from

Nabeelyousaf commented 2 years ago

hey @neon-ninja i m getting new error File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\facebook_scraper__init__.py", line 48, in set_cookies raise exceptions.InvalidCookies(f"Missing cookies with name(s): {missing_cookies}") facebook_scraper.exceptions.InvalidCookies: Missing cookies with name(s): ['c_user', 'xs'] image

Nabeelyousaf commented 2 years ago

The cookies.txt file needs to be in the same directory as where you run the script from

ok got it ,

Nabeelyousaf commented 2 years ago

hey @neon-ninja can you give me some detail on why I m getting this error and how I can solve it

neon-ninja commented 2 years ago

Make sure your cookies.txt includes those cookies (with the names c_user and xs)

sahullander commented 2 years ago

For those trying to figure out the cookie.txt information without install extensions: 1) Login to facebook. 2) Once logged in, right click anywehere on the page and select "Inspect". 3) At the top pf the developer panel, select the "Application" tab. 4) On the left side of the developer panel, find the "Storage" section and and expand the "Cookies" item (this should show the facebook URL once expanded). 5) Copy each "Name" and "Value" item into "cookies.txt" in a JSON format and save "cookies.txt".

Example "cookies.txt": { "xs" : "val1", "wd" : "val2", "usida" : "val3", "sb" : "val4", "presence" : "val5", "locale" : "val6", "fr" : "val7", "dpr" : "val8", "datr" : "val9", "c_user" : "val9" } NOTE The "Name" values are just an example and all of these may not be needed in order to run the tool.

haidergillani commented 1 year ago

Hey @neon-ninja any help on why my kernel keeps dying whenever I run the scrapping command? image