Skip to content

Instantly share code, notes, and snippets.

@lschmierer
Created June 7, 2017 13:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lschmierer/1e2b4612aea4eebedf0676c87a38dcb3 to your computer and use it in GitHub Desktop.
Save lschmierer/1e2b4612aea4eebedf0676c87a38dcb3 to your computer and use it in GitHub Desktop.
Facebook Event Attendant scraper
#!/usr/bin/env python
import sys
import json
import requests
# Usage
# ./scrape_fb_events_attendants.py event_id access_token | tr "}" "\n" | grep "Name to Search"
# access_token: https://developers.facebook.com/tools/explorer/
def main():
event_id = sys.argv[1]
access_token = sys.argv[2]
next_url = "https://graph.facebook.com/" + event_id + "/attending?limit=100&access_token=" + access_token
request_count = 0
# attendants = []
while len(next_url) > 0:
# print(str(request_count) + "_000 people fetched")
request_count = request_count + 1
r = requests.get(next_url)
result = json.loads(r.text)
# print(result)
print(result["data"])
if "next" in result["paging"]:
next_url = result["paging"]["next"]
else:
next_url = ""
# print(attendants)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment