Made user agent for initial request to duckduckgo api constant.

This commit is contained in:
NotoriousRebel 2019-01-01 23:33:18 -05:00
parent 5c64cb38f8
commit d684e22171
2 changed files with 5 additions and 3 deletions

View file

@ -242,7 +242,7 @@ def sendTCPRequest(self, server):
class DnsAsyncRequest(DnsRequest, asyncore.dispatcher_with_send):
" an asynchronous request object. out of date, probably broken "
" an asynchronous request object. out of date, probably broken "
def __init__(self, *name, **args):
DnsRequest.__init__(self, *name, **args)

View file

@ -21,7 +21,7 @@ def __init__(self, word, limit):
def do_search(self):
try: # do normal scraping
url = self.api.replace('x', self.word)
headers = {'User-Agent': getUserAgent()}
headers = {'User-Agent': googleUA}
r = requests.get(url, headers=headers)
except Exception as e:
print(e)
@ -74,6 +74,8 @@ def crawl(self, text):
return tmp
except Exception as e:
print('Exception occurred: ' + str(e))
import traceback as t
print(t.print_exc())
return []
def get_emails(self):
@ -85,4 +87,4 @@ def get_hostnames(self):
return rawres.hostnames()
def process(self):
self.do_search() # only need to search once since using API
self.do_search() # only need to search once since using API