Skip to content

Commit

Permalink
Merge pull request #1 from sarah-0-connor/json-decode
Browse files Browse the repository at this point in the history
catch JSON decode Error
  • Loading branch information
sarah-0-connor authored Feb 27, 2022
2 parents 8bba2bc + b861fc3 commit 83fbd7a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,19 @@ def mainth():
scraper.headers.update({'Content-Type': 'application/json', 'cf-visitor': 'https', 'User-Agent': random_useragent(), 'Connection': 'keep-alive',
'Accept': 'application/json, text/plain, */*', 'Accept-Language': 'ru', 'x-forwarded-proto': 'https', 'Accept-Encoding': 'gzip, deflate, br'})
logger.info("GET RESOURCES FOR ATTACK")
content = scraper.get(choice(HOSTS)).content
host = choice(HOSTS)
content = scraper.get(host).content
if content:
data = loads(content)
try:
data = json.loads(content)
except json.decoder.JSONDecodeError:
logger.info('Host {} has invalid format'.format(host))
sleep(5)
continue
except Exception:
logger.exception('Unexpected error. Host {}'.format(host))
sleep(5)
continue
else:
sleep(5)
continue
Expand Down

0 comments on commit 83fbd7a

Please sign in to comment.