Skip to content

Commit

Permalink
fix: use yarl to fix aiohttp compatible
Browse files Browse the repository at this point in the history
fix #24
  • Loading branch information
shidenggui committed Nov 16, 2016
1 parent 7ccc061 commit c912502
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion easyquotation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .api import *
from .helpers import get_stock_codes, update_stock_codes

__version__ = '0.4.6'
__version__ = '0.4.7'
__author__ = 'shidenggui'
7 changes: 5 additions & 2 deletions easyquotation/basequotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import aiohttp
import easyutils
import yarl

from . import helpers

Expand Down Expand Up @@ -47,10 +48,12 @@ def stocks(self, stock_codes):

async def get_stocks_by_range(self, params):
headers = {
'Accept-Encoding': 'gzip'
'Accept-Encoding': 'gzip, deflate, sdch',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.100 Safari/537.36'
}
url = yarl.URL(self.stock_api + params, encoded=True)
try:
async with self._session.get(self.stock_api + params, timeout=5, headers=headers) as r:
async with self._session.get(url, timeout=10, headers=headers) as r:
response_text = await r.text()
return response_text
except asyncio.TimeoutError:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
six
requests
aiohttp<=1.0.5
yarl
aiohttp>=1.1.1
easyutils
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
license='BSD',
url='https://github.com/shidenggui/easyquotation',
keywords='China stock trade',
install_requires=['requests', 'aiohttp<=1.0.5', 'six', 'easyutils'],
install_requires=['requests', 'aiohttp>=1.1.1', 'yarl', 'six', 'easyutils'],
classifiers=['Development Status :: 4 - Beta',
'Programming Language :: Python :: 3.5',
'License :: OSI Approved :: BSD License'],
Expand Down

0 comments on commit c912502

Please sign in to comment.