Last active
June 26, 2022 12:29
-
-
Save EdoardoVignati/3e3da8fd0a8a832dc42d8a455fbb93cb to your computer and use it in GitHub Desktop.
Find ID of a Facebook page
This file contains hidden or 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/env python | |
# Updated in june 2022 | |
import sys | |
import requests | |
import re | |
if len(sys.argv) != 2 or sys.argv[1] == "": | |
print("Provide a valid Facebook url page such as \"https://www.facebook.com/acme\"") | |
exit() | |
try: | |
response = requests.get(sys.argv[1]) | |
page_id = re.search("\"pageID\":\"[0-9]*\"", response.text) | |
print(page_id.group().split(":")[1][1:-1]) | |
except: | |
print("An error occurred. The URL is not valid (maybe a profile?) or the account is not public.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment