1 Star 0 Fork 0

朱烜宇/StockWaring

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
stock.py 615 Bytes
一键复制 编辑 原始数据 按行查看 历史
hello_python 提交于 2019-05-12 10:37 +08:00 . 完成0512
import requests
class Stock:
def __init__(self, stock_num):
self.stock_num = stock_num
def get_current(self):
"""
获取实时股票信息
:return:
"""
url = "http://hq.sinajs.cn/list={}".format(self.stock_num)
stock_info = requests.get(url).text
try:
current_price = stock_info.split(',')[3]
current_stock = stock_info.split(',')[0].split('="')[-1]
except Exception as e:
current_price = '0'
current_stock = '股票代码错误' + str(e)
return current_stock, current_price
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/pythonista/StockWaring.git
git@gitee.com:pythonista/StockWaring.git
pythonista
StockWaring
StockWaring
master

搜索帮助