Skip to content

Commit

Permalink
sina行情的获得改为使用 aiohttp
Browse files Browse the repository at this point in the history
  • Loading branch information
shidenggui committed Jan 14, 2016
1 parent ce319ab commit 192bfd5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions easyquotation/sina.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import re
import json
import time
import asyncio
import requests
import aiohttp
from . import helpers


Expand Down Expand Up @@ -39,9 +38,9 @@ def all(self):
return self.get_stock_data()

async def get_stocks_by_range(self, index):
loop = asyncio.get_event_loop()
response = await loop.run_in_executor(None, requests.get, self.sina_stock_api + self.stock_list[index])
self.stock_data.append(response.text)
async with aiohttp.get(self.sina_stock_api + self.stock_list[index]) as r:
response_text = await r.text()
self.stock_data.append(response_text)

def get_stock_data(self):
threads = []
Expand Down

0 comments on commit 192bfd5

Please sign in to comment.