Skip to content

Commit f809611

Browse files
Update 0.3.2
- Added error handling for running the script on a non whitelisted IP
1 parent b05e8e5 commit f809611

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

scrape.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import argparse
22
import threading
33
from datetime import datetime
4+
from json import decoder
45
from os import path, mkdir
56

67
import requests
@@ -26,7 +27,13 @@ def main():
2627
fetch_limit = 100
2728

2829
current_request = requests.get("https://scrape.pastebin.com/api_scraping.php?limit={0}".format(fetch_limit))
29-
current_json = current_request.json()
30+
try:
31+
current_json = current_request.json()
32+
33+
except decoder.JSONDecodeError:
34+
status("Unable to fetch latest pastes. Make sure your IP is whitelisted at "
35+
"https://pastebin.com/doc_scraping_api")
36+
exit(0)
3037

3138
status("Pastes fetched. Processing...")
3239
skipped_pastes = 0
@@ -90,7 +97,7 @@ def main():
9097

9198
AUTHOR = "SYRAPT0R"
9299
COPYRIGHT = "2019"
93-
VERSION = "0.3.1"
100+
VERSION = "0.3.2"
94101

95102
status("STARTING PASTA SCRAPER {0}, (c) {1} {2}".format(VERSION, COPYRIGHT, AUTHOR))
96103
print()

0 commit comments

Comments
 (0)