Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To fetch the information of users engaged in a post #158

Open
rowedenny opened this issue Jan 28, 2021 · 5 comments
Open

To fetch the information of users engaged in a post #158

rowedenny opened this issue Jan 28, 2021 · 5 comments

Comments

@rowedenny
Copy link

rowedenny commented Jan 28, 2021

Thanks for the work.

Following collecting the number of likes/comments/shares, I would like to collect the demographic information of the users who engaged in a post. More specifically, given a post with 98 likes, I would like to investigate the age and gender distribution of them. Thus I assume I need to firstly identify the users engaged in a post, and tracing back to their information, and check if there are publicly available gender and year of birth.

So I am wondering if it is possible to make it, given I can only get access to the profile information publicly available.

@rowedenny rowedenny changed the title To fetch the demographic information of users engaged in a post To fetch the information of users engaged in a post Jan 28, 2021
@kevinzg
Copy link
Owner

kevinzg commented Jan 29, 2021

I don't think Facebook freely publish that information.

@neon-ninja
Copy link
Collaborator

neon-ninja commented Apr 7, 2021

This PR (#201) in conjunction with this PR (#188, already merged) could make this possible (for commenters, not likers). Sample code:

posts = list(get_posts(post_urls=["https://m.facebook.com/story.php?story_fbid=1917763655047425&id=285708024919671"], cookies="cookies.txt", options={"comments":True}))
for commenter in posts[0]["comments_full"]:
    account = commenter.get("commenter_url").replace("https://facebook.com/", "").split("?")[0]
    profile = get_profile(account, cookies="cookies.txt", timeout=15)
    print(account, profile.get("Basic info"))

returns:

jess.anshaw {'Gender': 'Female'}
christine.salt.14 {'Gender': 'Female'}
paris.atkins15 None
Nephtis None
hannah.styles.96 {'Gender': 'Female'}
rebekah.nicholson.3 {'Gender': 'Female'}
jessica.holt.393 {'Gender': 'Female'}
alexwhitedgm {'Gender': 'Male'}
chelsie.foster.5 {'Gender': 'Female', 'Languages': 'English language'}
steven.gigacz {'Gender': 'Male'}

@neon-ninja
Copy link
Collaborator

As of #194 (comment) you can now extract users reacting to a post. Note that Like is just one of 7 possible reaction types.

@ambrel5
Copy link

ambrel5 commented May 2, 2021

Hi there, I keep getting an error when running the above code:

image

What am I doing wrong?

Edit:
To me, it seems that I am not handling cookies right, therefore the array comments_full is empty.

@neon-ninja
Copy link
Collaborator

yeah, if you're not logged in / passing cookies, commenter_url will always be None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants