New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pywencai

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pywencai

  • 0.12.3
  • PyPI
  • Socket score

Maintainers
1

PyPI version Downloads

知识星球

pywencai

获取同花顺问财数据

环境依赖

由于程序中执行了js代码,请先保证已安装了Node.js,需要版本v16+

未安装请自行安装

安装

pip install pywencai

由于问财接口策略经常发生变化,请安装最新版本使用,遇到问题时,优先尝试升级解决

视频教程

如何使用Python获取同花顺问财数据?全网最简单方法!

Demo

import pywencai

res = pywencai.get(query='退市股票', sort_key='退市@退市日期', sort_order='asc')
print(res)

API

get(**kwargs)

根据问财语句查询结果

参数

query

必填,查询问句

老版本的question参数1.0版本以后会弃用,请以后统一使用query参数

sort_key

非必填,指定用于排序的字段,值为返回结果的列名

sort_order

非必填,排序规则,至为asc(升序)或desc(降序)

page

非必填,查询的页号,默认为1

perpage

非必填,每页数据条数,默认值100,由于问财做了数据限制,最大值为100,指定大于100的数值无效。

loop

非必填,是否循环分页,返回多页合并数据。默认值为False,可以设置为True或具体数值。

当设置为True时,程序会一直循环到最后一页,返回全部数据。

当设置具体数值n时,循环请求n页,返回n页合并数据。

query_type

非必填,默认为stock,当查询的类型不是股票的时候需要传,取值如下:

取值含义
stock股票
zhishu指数
fund基金
hkstock港股
usstock美股
threeboard新三板
conbond可转债
insurance保险
futures期货
lccp理财
foreign_exchange外汇
retry

非必填,默认为10,表示请求失败后的重试次数。

sleep

非必填,默认为0,表示循环请求时,每次请求间隔多少秒。

log

非必填,默认为False,是否在控制台打印日志。

pro

非必填,默认为False,付费版传True,

必须传入cookie参数才能使用付费版

非必填,默认为None,免费版可以忽略,付费版必须传入cookie,获取付费使用权限。

pywencai.get(question='近3个月每日市盈率', pro=True, cookie='xxxx')

cookie获取方法,复制请求头中的Cookie字段值

cookie

request_params

非必填,默认为{},可以设置额外的request参数

pywencai.get(query='昨日涨幅', sort_order='asc', loop=True, log=True, request_params={ 'proxies': proxies })

具体参数参看:https://requests.readthedocs.io/en/latest/api/#requests.request

no_detail

非必填,默认为False,当为True时,查询一些详情类问题不再会返回字典,而返回None,可以保证查询结果类型一直为pd.DataFrameNone

find

非必填,默认为None,可以传一个数组,例如['600519', '000010'],数组内的对应标的会排列在DataFrame的最前面。

【注意】 1、该参数只有结果范围DataFrame时有效。2、配置该参数后,loop参数会失效,结果只会返回前100条。

user_agent

非必填,默认为None,可以自己传user_agent,不使用随机的生成的user_agent

返回值

当查询的是列表时,该方法返回一个pandasDataframe

当查询的是详情时,该方法返回一个字典,字典中可能包含若干个文本和Dataframe

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc