以下是一个简单的 Python 程序,可以获取 A 股资金流动比率:

import requests
from bs4 import BeautifulSoup

def get_fund_flow_ratio(code):
    url = 'http://quote.eastmoney.com/sh{0}.html'.format(code)
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')
    div = soup.find('div', {'class': 'cwzb'})
    table = div.find_all('table')[1]
    tr = table.find_all('tr')[5]
    td = tr.find_all('td')[1]
    return td.text.strip()

if __name__ == '__main__':
    code = '601318' # 中国平安股票代码
    fund_flow_ratio = get_fund_flow_ratio(code)
    print('资金流动比率:{0}'.format(fund_flow_ratio))

在这个程序中,我们使用了 requests 库来获取网页内容,使用了 BeautifulSoup 库来解析 HTML。get_fund_flow_ratio 函数接受一个股票代码作为参数,然后从东方财富网上获取该股票的资金流动比率,并返回结果。我们在主程序中调用该函数来获取中国平安股票的资金流动比率,并将结果打印出来

使用python编程获取A股资金流动比率

原文地址: https://www.cveoy.top/t/topic/eFQV 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录