From 84af726754cefb9eff8431971ac852094d777252 Mon Sep 17 00:00:00 2001 From: Jay Townsend Date: Sun, 11 Aug 2019 05:00:04 +0100 Subject: [PATCH] Fix threatcrowd and move to grequests --- theHarvester/discovery/threatcrowd.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/theHarvester/discovery/threatcrowd.py b/theHarvester/discovery/threatcrowd.py index b11e9b6a..dd7287bd 100644 --- a/theHarvester/discovery/threatcrowd.py +++ b/theHarvester/discovery/threatcrowd.py @@ -1,6 +1,6 @@ from theHarvester.lib.core import * from theHarvester.parsers import myparser -import requests +import grequests class SearchThreatcrowd: @@ -13,11 +13,12 @@ def __init__(self, word): self.counter = 0 def do_search(self): - url = f'https://www.threatcrowd.org/searchApi/v2/domain/report/?domain={self.word}' + base_url = f'https://www.threatcrowd.org/searchApi/v2/domain/report/?domain={self.word}' headers = {'User-Agent': Core.get_user_agent()} try: - request = requests.get(url, headers=headers) - self.results = request.text + request = grequests.get(base_url, headers=headers) + data = grequests.map([request]) + self.results = data[0].content.decode('UTF-8') except Exception as e: print(e) self.totalresults += self.results @@ -27,4 +28,5 @@ def get_hostnames(self): def process(self): self.do_search() + self.get_hostnames() print('\tSearching results.')