獲取新浪可轉債t+0列表,附上python代碼


​​​​​​​
@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)

沒什麼好說的,分享出來,拿來就是用

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章