Skip to content

Instantly share code, notes, and snippets.

@EdoardoVignati
Last active June 26, 2022 12:29
Show Gist options
  • Save EdoardoVignati/3e3da8fd0a8a832dc42d8a455fbb93cb to your computer and use it in GitHub Desktop.
Save EdoardoVignati/3e3da8fd0a8a832dc42d8a455fbb93cb to your computer and use it in GitHub Desktop.
Find ID of a Facebook page
#!/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