Created
June 7, 2017 13:03
-
-
Save lschmierer/1e2b4612aea4eebedf0676c87a38dcb3 to your computer and use it in GitHub Desktop.
Facebook Event Attendant scraper
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 | |
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