PDF Support, Description, & image acquisition needs work.

This commit is contained in:
th3r00t
2020-12-12 13:24:17 -05:00
parent 11fe1c7d40
commit 7784f12c29
3 changed files with 79 additions and 13 deletions

View File

@@ -1,8 +1,6 @@
#!/usr/bin/python
import sys
import requests
import json
# sys.path.insert(1, 'lib/')
@@ -33,3 +31,22 @@ class DuckDuckGo:
return image.raw
else:
return False
def description_result(self, query):
_key = "&format=json"
try:
query = query.string
except AttributeError:
pass
try:
_r = json.loads(requests.get(self.url + query + _key).text)
except Exception as e:
return None
if len(_r["Results"]) == 0:
return None
else:
try:
return _r["Abstract"]
except AttributeError:
return None
return _r.Results[0]