Micro-sheep / Micro-sheep/efinance

efinance 被限流报错的解决方案 cookie版

Open
#235 5 comments 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
4.1k
Forks
755
PR merge metrics
No merged PRs in 30d

Description

很久没用efinance,今天看了下接口都无法访问

Image

去年有段时间,接口无法访问时,东财当时是根据ip做了限制,只要到东财官网上刷新下,重新验证身份,接口也能访问了.
现在是直接要用登陆的cookie信息验证.

1. 上东财官网,登陆
2. chrome或者edge,查看cookie,获取到 ct=xxxxx 那部分 ( 只要删除ct这部分cookie, api接口会报错, 只能重新登陆后才能访问 push2 的http)

Image

3. 修改 efinance 的源码

`
# 定义包含 cookie 的 headers
EASTMONEY_REQUEST_HEADERS = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
'Referer': 'http://quote.eastmoney.com/',
'Cookie': 'ct=您的cookie字符串' # 直接在这里添加 cookie
}
`

最后,还是建议做好缓存,减少访问频次.
现在我的方案是 tdx 的历史k线数据 + futu 的get_rehab 获得复权因子后自己计算.
东财的接口主要是看整体

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue reports that Eastmoney push2 requests now require a logged-in ct cookie and includes a proposed request-header snippet. Start by locating efinance's Eastmoney request entry point and checking how its current headers and request frequency are handled. Done means the affected API access path has a supported cookie-based solution and the behavior is verified without exposing a user's credential.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.