<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>排名系统 on 格物堂</title><link>https://gewutang.cn/tags/%E6%8E%92%E5%90%8D%E7%B3%BB%E7%BB%9F/</link><description>Recent content in 排名系统 on 格物堂</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><lastBuildDate>Fri, 07 Sep 2012 00:00:00 +0000</lastBuildDate><atom:link href="https://gewutang.cn/tags/%E6%8E%92%E5%90%8D%E7%B3%BB%E7%BB%9F/index.xml" rel="self" type="application/rss+xml"/><item><title>获取上市公司主要财务指标</title><link>https://gewutang.cn/2012/09/07/get-financial-data-from-web/</link><pubDate>Fri, 07 Sep 2012 00:00:00 +0000</pubDate><guid>https://gewutang.cn/2012/09/07/get-financial-data-from-web/</guid><description>&lt;p&gt;写了一段获取上市公司主要财务指标的代码：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;# 加载XML包&#10;library(XML)&#10;####id:股票代码&#10;####year:年度&#10;get.finance &amp;lt;- function(id,year,...){&#10; web &amp;lt;- paste(&amp;quot;http://money.finance.sina.com.cn/corp/go.php/vFD_FinancialGuideLine/stockid/&amp;quot;,id,&amp;quot;/ctrl/&amp;quot;,year,&amp;quot;/displaytype/4.phtml&amp;quot;,sep=&amp;quot;&amp;quot;)&#10; tables &amp;lt;- readHTMLTable(web)$BalanceSheetNewTable0&#10; colnames(tables)&amp;lt;-tables[1,]&#10; tables &amp;lt;- tables[-1,]&#10; return(tables)&#10;}&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;简单演示一下：&lt;/p&gt;&#10;&lt;pre&gt;&lt;code class="language-r"&gt;library(XML)&#10;res &amp;lt;- get.finance(&amp;quot;000002&amp;quot;,&amp;quot;2012&amp;quot;)&#10;&lt;/code&gt;&lt;/pre&gt;&#10;&lt;p&gt;基于这些财务数据和价格数据，就可以着手建立股票排名系统了。&lt;/p&gt;&#10;</description></item></channel></rss>