Open songsh opened 3 years ago
Use the parameter credentials
, and pass a tuple. For example, get_posts("Nintendo", credentials=("user@mail.com","password"))
Is it still working? I've been using the credentials of a new create account and it just pops with unsuccesful login error.
Still working fine for me
question: if I set the credentials parameter, can I avoid adding the cookies?
i.e. facebook_scraper.get_page_info(identifier, credentials=(user, password))
I get LoginRequired exception: facebook_scraper.exceptions.LoginRequired: A login (cookies) is required to see this page
get_page_info
doesn't support the credentials parameter the same way as get_posts
, you would probably want to decouple it, like so:
from pprint import pprint
from facebook_scraper import _scraper, get_page_info
_scraper.login(user, password)
pprint(get_page_info(identifier))
Thanks, so if I provide user and password can I avoid passing cookies?
Yes
I have a couple more questions, and probably very python-noob (sorry!), still related to login with user and password. Let's say I want to use multiple accounts for scraping, and the scraping may happen concurrently for the different accounts.
So I initialize a dictionary of scrapers, something like this:
users = ["user1@something.com", "user2@something.com", "user3@something.com"]
scrapers = {}
for user in users:
scraper = FacebookScraper()
for i in range(3):
try:
scraper.login(user, <user password>)
if scraper.is_logged_in():
print("User " + user + " logged in.")
scrapers[user] = scraper
break
except LoginError:
pass
except TemporarilyBanned:
print("User " + user + " is temporarily banned.")
break
1) Do I get to have multiple instances of scraper class in scrapers dict that stay logged in and I can use concurrently, and thread safe?
2) Moreover, usually the first login attempt always fails, it succeeds only on second attempt, is this normal?
For some reason I get login unsuccessful?
from facebook_scraper import get_posts
for post in get_posts('113060560534111', pages=5, credentials=("******@hotmail.com","*****")):
print(post['text'][:50])
File "C:\Users\Raiko\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\facebook_scraper\facebook_scraper.py", line 567, in login raise exceptions.LoginError("Login unsuccessful") facebook_scraper.exceptions.LoginError: Login unsuccessful
Can you login with those credentials in an incognito window on m.facebook.com?
Can you login with those credentials in an incognito window on m.facebook.com?
How could I attempt this? I tried a different approach by saving cookie, and it seem to work, but I really want to be able to login with the credentials tuple, if possible...
Go to https://m.facebook.com/ in your browser, in an incognito session if you're using Chrome or inprivate session if you're using Firefox
Is a login_error.html file generated in your current working directory? If so, can you upload it?
Can you login with those credentials in an incognito window on m.facebook.com?
Yeah, I can login with my credentials on incognito
Is a login_error.html file generated in your current working directory? If so, can you upload it?
It says that file has been deleted. Can you just upload it to this thread directly, by drag & drop?
It says that file has been deleted. Can you just upload it to this thread? login_error.zip
It says that file has been deleted. Can you just upload it to this thread directly, by drag & drop?
It wasn't supported so I had to zip it
The error message is in Swedish, which means your login page was in Swedish too. The login function is currently only designed to work with the English version of the m.facebook.com login page.
The error message is in Swedish, which means your login page was in Swedish too. The login function is currently only designed to work with the English version of the m.facebook.com login page.
How can I make it not be Swedish?
Use a proxy or VPN from an English speaking country?
Use a proxy or VPN from an English speaking country?
Changed to U.S.A now, the error I get now is "login approval needed"
Now you need to approve the new login from a web browser that is logged into that account. You should have got a notification
Now you need to approve the new login from a web browser that is logged into that account. You should have got a notification
I approved it 2 times, but when I run the command prompt again, it asks for login approval again
Maybe I will be forced to use the cookies file? Using NordVPN to USA just keeps asking for login approval, even though I approved myself many times now
First install the latest master branch so that you get that commit with pip install git+https://github.com/kevinzg/facebook-scraper.git
. Then try again.
First install the latest master branch so that you get that commit with
pip install git+https://github.com/kevinzg/facebook-scraper.git
. Then try again.
So tried 4 times, had to approve on all 4 First time: had to change PW other 3 times: logged in after confirming with the number sent to my mail
Sounds like it might be easier to just use cookies then. Probably FB detects that thousands of people use that IP address so don't mark it as trusted even when you approve the login.
Sounds like it might be easier to just use cookies then. Probably FB detects that thousands of people use that IP address so don't mark it as trusted even when you approve the login.
Yeah possible, I changed to UK now instead, now I get login unsuccessful, so I suppose only U.S would work
update: chose canada and it works!
i see the readme, no mention the username, passwor, how to set?