Fix threatcrowd and move to grequests

This commit is contained in:
Jay Townsend 2019-08-11 05:00:04 +01:00
parent 81c78a248b
commit 84af726754

View file

@ -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.')