facebook-scraper icon indicating copy to clipboard operation
facebook-scraper copied to clipboard

How would I format cookies?

Open SenExus opened this issue 3 years ago • 10 comments

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)

SenExus avatar Feb 05 '22 22:02 SenExus

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.

SenExus avatar Feb 05 '22 22:02 SenExus

They should be in Netscape format

neon-ninja avatar Feb 06 '22 23:02 neon-ninja

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

SenExus avatar Feb 09 '22 01:02 SenExus

Yes

neon-ninja avatar Feb 09 '22 01:02 neon-ninja

https://github.com/kevinzg/facebook-scraper/commit/96a49408081399c9687f9b637d06c6ccee82ca81 should make it clearer what line is wrong

neon-ninja avatar Feb 09 '22 04:02 neon-ninja

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?

SenExus avatar Feb 11 '22 00:02 SenExus

Please post your code

neon-ninja avatar Feb 11 '22 00:02 neon-ninja

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)

SenExus avatar Feb 11 '22 19:02 SenExus

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"))

neon-ninja avatar Feb 11 '22 19:02 neon-ninja

This solved my issue, thank you!

SenExus avatar Feb 12 '22 15:02 SenExus