-
Notifications
You must be signed in to change notification settings - Fork 0
/
pwnscrap.py
35 lines (28 loc) · 974 Bytes
/
pwnscrap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import re
import json
import argparse
import cloudscraper
def parse():
parser = argparse.ArgumentParser(description='Check if your email has been pwned')
parser.add_argument('-email', metavar="email", type=str, required=True, help='Email to check for breaches')
args = parser.parse_args()
return args
def scrap_and_store(email):
url = f"https://haveibeenpwned.com/unifiedsearch/{email}"
scraper = cloudscraper.create_scraper()
try:
result = scraper.get(url)
except Exception as e:
print(f"Error: Following exception occured!\n{e}\nPlease retry once more!")
else:
print('Info: Done Scrapping!')
if result.text!='':
print('Warning: Breach found!')
with open("data/{}.json".format(email), "w") as f:
json.dump(result.json(), f , sort_keys=True, indent=4)
print(f"Info: Data saved at /data/{email}.json")
else:
print('Info: No breach found for this email.')
if __name__ == "__main__":
email = parse().email
scrap_and_store(email)