股票接口
股票数据的获得
- http/javascript接口
- web-service接口
使用方法
<script type="text/javascript" src="http://hq.sinajs.cn/list=sh600300" charset="gb2315">
</script>
<script type="text/javascript">
var elements=hq_str_sh600300.split(",");
document.write("current price:"+elements[3]);
</script>
股票历史数据接口
$stockCode = 600000
$url = "http://money.finance.sina.com.cn/corp/go.php/vMS_MarketHistory/stockid/{0}.phtml"
-f $stockCode
$wc = New-Object System.Net.WebClient
$content = $wc.DownloadString($url)
$reg = "<a target='_blank's+href='http://biz.finance.sina.com.cn/stock/history_min.php?
symbol=shd{6}&date=d{4}-d{2}-d{2}'>s*([^s]+)s+</a>s*</div></td>s*<td[^d]*([^<]*)</div>
</td>s+<td[^d]*([^<]*)</div></td>s+<td[^d]*([^<]*)</div></td>s+<td[^d]*([^<]*)</div></td>s+"
$result = [RegEx]::matches($content, $reg)
foreach($item in $result)
{
$date = $item.Groups[1].Value # 时间
$opening = $item.Groups[2].Value # 开盘
$maxHigh = $item.Groups[3].Value # 最高
$closing = $item.Groups[4].Value # 收盘
$maxLow = $item.Groups[5].Value # 最低
Write-Host $date $opening $maxHigh $closing $maxLow
}
网友评论