Last active
November 23, 2019 05:26
-
-
Save gsscoder/1708235c2d6a47b4473e046c4afae7ae to your computer and use it in GitHub Desktop.
Scrapes Facebook to gather profile IDs
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
""" | |
fbscrap_getIDs.py: | |
Used to gather real Facebook profile IDs (https://github.com/gsscoder/facebook-snooper/). | |
For version: 0.4.3 | |
Usage: python3 fbscrap_getIDs output_file.txt | |
""" | |
import requests | |
import json | |
import sys | |
import random | |
import getpass | |
import facebook_snooper | |
names_json = requests.get( | |
'https://gist.githubusercontent.com/gsscoder/e0e905fbef23376aabfa695d85d8ef5c/raw/c250e439541647e3b2125922a04e1323ae51ff7a/names.json') | |
names = json.loads(names_json.content) | |
random.shuffle(names) | |
username = input('username: ') | |
password = getpass.getpass() | |
all_ids = [] | |
print('Attempting connection...') | |
try: | |
with facebook_snooper.default_session() \ | |
.log_in(username, password) as fb: | |
for name in names[:10]: | |
print(f'Searching Profile IDs for {name}.') | |
results = fb.search(name) | |
ids = [id for id, _, _ in results] | |
all_ids.extend(ids) | |
with open(sys.argv[1], 'w') as out: | |
out.write('\n'.join(all_ids)) | |
except Exception as err: | |
sys.stderr.write(f'ERROR: {err}\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment