Get user_id from username #371
Answered
by
neon-ninja
alvaroserrrano
asked this question in
Q&A
-
Hi, Thanks for creating this. How can we get the id of a user entering its username or even profile_name? |
Beta Was this translation helpful? Give feedback.
Answered by
neon-ninja
Jun 29, 2021
Replies: 1 comment 6 replies
-
The from facebook_scraper import get_profile
from pprint import pprint
pprint(get_profile("zuck")) outputs {'About': "I'm trying to make the world a more open place.",
'Education': 'Harvard University\n'
'Computer Science and Psychology\n'
'30 August 2002 - 30 April 2004\n'
'Phillips Exeter Academy\n'
'Classics\n'
'School year 2002\n'
'Ardsley High School\n'
'High School\n'
'September 1998 - June 2000',
'Favourite Quotes': '"Fortune favors the bold."\n'
'- Virgil, Aeneid X.284\n'
'\n'
'"All children are artists. The problem is how to remain '
'an artist once you grow up."\n'
'- Pablo Picasso\n'
'\n'
'"Make things as simple as possible but no simpler."\n'
'- Albert Einstein',
'Name': 'Mark Zuckerberg',
'Places lived': [{'link': '/profile.php?id=104022926303756&refid=17',
'text': 'Palo Alto, California',
'type': 'Current town/city'},
{'link': '/profile.php?id=105506396148790&refid=17',
'text': 'Dobbs Ferry, New York',
'type': 'Home town'}],
'Work': 'Chan Zuckerberg Initiative\n'
'1 December 2015 - Present\n'
'Facebook\n'
'Founder and CEO\n'
'4 February 2004 - Present\n'
'Palo Alto, California\n'
'Bringing the world closer together.',
'cover_photo': 'https://scontent.fakl1-2.fna.fbcdn.net/v/t31.18172-8/fr/cp0/e15/q65/19575079_10103832396388711_8894816584589808440_o.jpg?_nc_cat=109&ccb=1-3&_nc_sid=ed5ff1&_nc_ohc=JWr-Ynp5mrMAX-ZRcWx&_nc_ht=scontent.fakl1-2.fna&tp=14&oh=0a80f369d0ad77f855f91415b977f0fb&oe=60DED498',
'id': '4',
'profile_picture': 'https://scontent.fakl1-2.fna.fbcdn.net/v/t1.6435-1/fr/cp0/e15/q65/79515135_10111007623880301_5111576226921709568_n.jpg?_nc_cat=1&ccb=1-3&_nc_sid=dbb9e7&_nc_ohc=QAH7s-CmNV0AX9SYhfr&_nc_ht=scontent.fakl1-2.fna&tp=14&oh=e99db3b0a0b720fda3524ff26545bd35&oe=60E029D6'} Note the |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
neon-ninja
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
get_profile
function should do it. Here's an example:outputs