Kinsoku jikou desu新浪股票接口变动(python)

1、问题描述

在B站看一个up主的视频爬取实时股票数据,结果新浪接口变化了,显示Kinsoku jikou desu

网上百度了半天只有Java版,查了一些资料然后又问了别人,解决了这个小问题。

现在新浪接口访问需要添加访问头。

2.源码

import requests

def getTick():#获取某股票最新成交价
    url = "http://hq.sinajs.cn/list=sh600519"
    headers={'Referer':'https://finance.sina.com.cn/'}
    page = requests.get(url,headers=headers)


    stock_info = page.text
    print(stock_info)
    mt_info = stock_info.split(",")#爬取到数据信息

    last = float(mt_info[1])
    trade_datetime = mt_info[30] + ' '+ mt_info[31]#交易时间

    tick = (last,trade_datetime)

    return tick#得到股票最新成交价、时间
last_tick = getTick()#进入网页获取数据
print(last_tick)

3、参考链接

https://blog.csdn.net/sunshineGGB/article/details/122983317https://blog.csdn.net/sunshineGGB/article/details/122983317若有错误请指正,谢谢!

  • 21
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
您可以使用Pythonpython-docx模块来设置表格的边框磅数。具体来说,您可以使用Table对象的style属性来设置表格的样式,然后使用TableStyle对象来设置样式的属性,包括边框磅数。 下面是一个例子,展示如何使用python-docx模块来设置表格的边框磅数: ```python from docx import Document from docx.shared import Pt from docx.enum.table import WD_TABLE_ALIGNMENT from docx.enum.text import WD_ALIGN_PARAGRAPH from docx.oxml.ns import qn # 创建一个新的文档 document = Document() # 添加一个表格 table = document.add_table(rows=3, cols=3) # 设置表格的样式 table.style = 'Table Grid' # 获取表格的样式 style = table.style # 设置表格样式的边框磅数 style.font.size = Pt(12) style.font.name = '宋体' style.paragraph_format.alignment = WD_ALIGN_PARAGRAPH.CENTER style.table_alignment = WD_TABLE_ALIGNMENT.CENTER style.borders.top.size = Pt(1) style.borders.bottom.size = Pt(1) style.borders.left.size = Pt(1) style.borders.right.size = Pt(1) style.borders.top.color.rgb = (0, 0, 0) style.borders.bottom.color.rgb = (0, 0, 0) style.borders.left.color.rgb = (0, 0, 0) style.borders.right.color.rgb = (0, 0, 0) style.paragraph_format.space_before = Pt(0) style.paragraph_format.space_after = Pt(0) style.paragraph_format.line_spacing = 1.5 style.paragraph_format.first_line_indent = Pt(0) style.paragraph_format.keep_together = True style.paragraph_format.keep_with_next = True style.paragraph_format.widow_control = True style.paragraph_format.kinsoku = True style.paragraph_format.kinsoku_locale_id = qn('ja-JP') # 保存文档 document.save('table.docx') ``` 在上述代码中,我们首先创建了一个新的文档,然后添加了一个3行3列的表格。接着,我们设置了表格的样式为“Table Grid”,并获取了表格的样式对象。最后,我们使用样式对象的borders属性来设置表格的边框磅数。在这个例子中,我们将表格的边框磅数设置为1磅。 请注意,以上代码仅供参考,您可以根据自己的需求进行修改和定制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值