Skip to content

Commit

Permalink
Version 2.1.1: Some bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Feb 9, 2020
1 parent 491d9f2 commit a6981bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
5 changes: 1 addition & 4 deletions duckpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ def search(self, query, exact_match=False, **kwargs):
http = urllib3.ProxyManager(proxy)
else:
http = self.http
if self.random_ua:
headers = {'User-Agent': secrets.token_hex(5) + '/1.0'}
else:
headers = None
headers = {'User-Agent': secrets.token_hex(5) + '/1.0'} if self.random_ua else None

r = http.request('GET', ddg_url, fields=dict(q=query, **kwargs), headers=headers)

Expand Down
8 changes: 2 additions & 6 deletions duckpy/aio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ def __init__(self, proxies=None, random_ua=True):
async def search(self, query, exact_match=False, **kwargs):
if exact_match:
query = '"%s"' % query
if self.proxies:
proxy = random.choice(self.proxies)
if self.random_ua:
headers = {'User-Agent': secrets.token_hex(5) + '/1.0'}
else:
headers = None
proxy = random.choice(self.proxies) if self.proxies else None
headers = {'User-Agent': secrets.token_hex(5) + '/1.0'} if self.random_ua else None

async with aiohttp.ClientSession() as session:
r = await session.get(ddg_url, proxy=proxy, params=dict(q=query, **kwargs), headers=headers)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name='duckpy',
version='2.1.0',
version='2.1.1',

packages=['duckpy', 'duckpy.aio'],
install_requires=['bs4', 'urllib3', 'aiohttp', 'certifi'],
Expand Down

0 comments on commit a6981bb

Please sign in to comment.