@classmethod
def get_page_convertibleBonds(cls, pageIndex, retry_count=10):
url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeDataSimple?page=%d&num=1000&sort=symbol&asc=1&node=hs_z&_s_r_a=page" % (
pageIndex)
for _ in range(retry_count):
time.sleep(1)
try:
request = Request(url)
lines = urlopen(request, timeout=10).read()
if len(lines) < 15: # no data
return None
except Exception as e:
print(e)
else:
datas = json.loads(lines.decode('utf-8') if ct.PY3 else lines)
return datas
raise IOError(ct.NETWORK_URL_ERROR_MSG)
没什么好说的,分享出来,拿来就是用