facebook-scraper
facebook-scraper copied to clipboard
How would I format cookies?
Apologies, but I don't exactly know how to format the cookies within the cookies.txt file, as, no matter how I try, I get the error:
raise exceptions.InvalidCookies(f"Cookies are in an invalid format: {e}") facebook_scraper.exceptions.InvalidCookies: Cookies are in an invalid format: not enough values to unpack (expected 7, got 1)
I searched, but it didn't seem like there were was any info on how to format them, so I opened this issue; apologies if this is a cause of inconvenience.
They should be in Netscape format
Like this?
.facebook.com TRUE / TRUE 1703608474 datr bla
.facebook.com TRUE / TRUE 1703620811 sb bla
.facebook.com TRUE / TRUE 1675876677 c_user bla
.facebook.com TRUE / TRUE 1644975547 dpr bla
.facebook.com TRUE / TRUE 1802354560 oo bla
.facebook.com TRUE / TRUE 1675876677 xs bla
.facebook.com TRUE / TRUE 0 presence bla
Yes
https://github.com/kevinzg/facebook-scraper/commit/96a49408081399c9687f9b637d06c6ccee82ca81 should make it clearer what line is wrong
Thank you for your response, but I seem to be having another issue. When I run the "get_profile" function with all the valid stuff (cookies, account, etc), it outputs nothing. I can still print things and when I mess up the cookies it still spits out an error, but when I run it with all the proper info, it starts, then closes about 3 seconds later. Any idea why this is happening?
Please post your code
from facebook_scraper import get_profile
get_profile("joebiden", cookies = "cookies.txt")
cookies.txt:
.facebook.com TRUE / TRUE (important numbers here) datr (token here)
.facebook.com TRUE / TRUE (important numbers here) sb (token here)
.facebook.com TRUE / TRUE (important numbers here) c_user (token here)
.facebook.com TRUE / TRUE (important numbers here) xs (token here)
.facebook.com TRUE / TRUE (important numbers here) presence (token here)
get_profile
doesn't print anything on it's own, it returns a dict. Try print(get_profile("joebiden", cookies="cookies.txt"))
or, after from pprint import pprint
, pprint(get_profile("joebiden", cookies="cookies.txt"))
This solved my issue, thank you!