Giter VIP home page Giter VIP logo

Comments (2)

albertandking avatar albertandking commented on June 29, 2024 1

1.Describe the bug**

# 调用雪球数据, r = requests.get() 返回400 ,查看本地浏览器cookie,
# 填写 "Cookie":"xqat=4b8bc7136c9fd7b4395f9ca0a65c38363243df2b", 成功,

stock_individual_spot_xq_df = stock_individual_spot_xq(symbol="SH000001")
print(stock_individual_spot_xq_df)
  1. akshare Version v1.13.30.

3.查看相关资料,雪球反爬虫 cookie 进行了加密,具体信息请查看:

https://blog.csdn.net/m0_59585734/article/details/134074988

4.解决方案如下:(其他雪球接口,没有测试,如果也有问题,以此类推)

def stock_individual_spot_xq(
        symbol: str = "SH600000",
        timeout: float = None,
) -> pd.DataFrame:
    """
    雪球-行情中心-个股
    https://xueqiu.com/S/SH600000
    :param symbol: 证券代码,可以是 A 股代码,A 股场内基金代码,A 股指数,美股代码, 美股指数
    :type symbol: str
    :param timeout: choice of None or a positive float number
    :type timeout: float
    :return: 证券最新行情
    :rtype: pandas.DataFrame
    """

    # 自动处理cookie爬取雪球网
    session = requests.Session()
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
    }
    # 向雪球网首页发送一条请求,获取cookie
    session.get(url="https://xueqiu.com", headers=headers)

    url = f"https://stock.xueqiu.com/v5/stock/quote.json?symbol={symbol}&extend=detail"
    r = session.get(url, headers=headers, timeout=timeout)
   ...

感谢反馈问题并提供解决方案,已修复该问题,升级到 AKShare 1.13.31 使用

from akshare.

WheatMaThink avatar WheatMaThink commented on June 29, 2024

感谢作者,提供这么优秀的开源项目。

from akshare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.