Created
April 9, 2015 17:20
-
-
Save paulschreiber/96f88a4cbb0d62cfe666 to your computer and use it in GitHub Desktop.
Facebook User ID fetcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import requests | |
import re | |
url = 'https://www.facebook.com/zuck' | |
idre = re.compile('"entity_id":"([0-9]+)"') | |
page = requests.get(url) | |
print idre.findall(page.content) | |
# One-liner | |
# python -c 'import requests, re; print re.findall("\"entity_id\":\"([0-9]+)\"", requests.get("https://facebook.com/zuck").content)[0] + "\n"' |
This will not work for private accounts
Is there a way to verify a set of numbers in a file to see who has a Facebook account?
Using python
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd suggest using the lite version of fb, i.e.
https://mbasic.facebook.com/<USERNAME>
(orhttps://touch.facebook.com/<USERNAME>
, which is easier to parse afterwards) as the returned page is much smaller. Of course in that caseentity_id
won't do anymore, so one might resort to looking forowner_id=
or the more robustphoto.php?fbid=99999999999999999&id=1111111111
(where111....
is the id we're looking for).P.S.
The lite sites support the
https://<site_type>.facebook.com/app_scoped_user_id/9876543210
endpoint.