采集股票程序 可以采集当天最新价格 涨跌情况 输出index.php
var qp = "/bbs/"
var pagenum = 1;
var pagecount = 1;
var pagesize = 30;
var skip = 0;
var total = 0;
var digits = 2;
var firstpage = 1;
var sort = "ZDF";
var orderby = "desc";
var max = 0;
function loadQuoteCommentList() {
var c = "http://f10.stockstar.com/f10/V_BS_COMMENT/skip=" + skip + "&limit=" + pagesize + "&sort=" + sort + "%20" + orderby + "&full=1&d=" + getURLTimeStamp();
var b = true;
var d = TrimWhiteSpace(document.getElementById("searchcode").value);
if (d != "" && d != "代码/简称") {
if (IsNumber(d)) {
c += "&filter-STOCKCODE-str=" + d
} else {
if (isChinese(d)) {
c += "&filter-STOCKSNAME-str=" + d
} else {
b = false;
alert("请输入代码/简称")
}
}
}
if (b) {
var a = document.createElement("script");
document.body.appendChild(a);
a.onload = function() {
bindQuoteComment();
document.body.removeChild(this)
};
a.onreadystatechange = function() {
if (this.readyState == "loaded") {
bindQuoteComment();
document.body.removeChild(this)
}
};
a.src = c
}
}
function bindQuoteComment() {
if (V_BS_COMMENT) {
total = V_BS_COMMENT.total_rows;
var d = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><thead><tr><th width="5%" height="48" valign="top">序号</th><th width="11%" valign="top"><div class="sort"><p>代码</p><div style="width:30px;margin:0 auto;height:25px;" id="el_STOCKCODE"><span class="gray_sort" onclick="sortField(\'STOCKCODE\',1)"></span><span class="down_sort" onclick="sortField(\'STOCKCODE\',2)"></span></div></div></th><th width="10%" valign="top">简称</th><th width="12%" valign="top"><div class="sort"><p>最新价</p><div style="width:30px;margin:0 auto;height:25px;" id="el_SPJG"><span class="gray_sort" onclick="sortField(\'SPJG\',1)"></span><span class="down_sort" onclick="sortField(\'SPJG\',2)"></span></div></div></th><th width="11%" valign="top"><div class="sort"><p>涨跌幅</p><div style="width:30px;margin:0 auto;height:25px;" id="el_ZDF"><span class="gray_sort" onclick="sortField(\'ZDF\',1)"></span><span class="down_sort" onclick="sortField(\'ZDF\',2)"></span></div></div></th><!--<th width="33%" valign="top">评论</th><th width="6%" valign="top"><br /></th><th width="6%" valign="top"><br /></th><th width="6%" valign="top">资金<br />流向</th></tr>-->'; + "</thead><tbody>";
if (total > 0) {
pagecount = parseInt(total / pagesize);
if (total % pagesize != 0) {
pagecount++
}
var c = V_BS_COMMENT.rows;
document.getElementById("tradedate").innerHTML = getTradeDate(c[0].DECLAREDATE);
var a = pagenum == 1 ? 1 : (pagenum - 1) * pagesize + 1;
for (var b in c) {
d += '<tr class="' + (a % 2 == 0 ? "td3": "td4") + '" onmouseover="ChangeRowBg(this,event)" onmouseout="ChangeRowBg(this,event)" onmousedown="ChangeRowBg(this,event)"><td align="center">' + a + '</td><td align="center" id="el_STOCKCODE_' + b + '"><a href="' + getQuoteGSUrl(c[b].STOCKCODE, c[b].MARKET_TYPE_ID) + '">' + c[b].STOCKCODE + '</a></td><td align="center"><a href="' + getQuoteGSUrl(c[b].STOCKCODE, c[b].MARKET_TYPE_ID) + '">' + c[b].STOCKSNAME + '</a></td><td align="right" id="el_SPJG_' + b + '">' + setStyle(c[b].SPJG, c[b].ZDF, 0, "") + '</td><td align="right" id="el_ZDF_' + b + '">' + setStyle(c[b].ZDF, c[b].ZDF, 0, "%") + '</td><!--屏蔽<td align="center">' + c[b].COMMENT + '</td>--><!--屏蔽<td align="center"><br /></td><td align="center"><br /></td><td align="center"><a href="' + getZjlx(c[b].STOCKCODE, c[b].MARKET_TYPE_ID) + '"><img src="http://i.ssimg.cn/images/stock/default2010/img_stock.gif" width="20" height="20" alt="个股资金流向" title="个股资金流向"/></a></td></tr>-->';
a++;
max = b
}
} else {
d += '<tr><td align="center" colspan="9">暂无相关数据</td></tr>'
}
d += "</tbody></table>";
document.getElementById("datalist").innerHTML = d;
if (total > 0) {
getSortTag(sort);
getPageList()
}
}
}
function getZjlx(b, a) {
if (parseInt(a) == 1) {
return qp + b + ".html"
} else {
return qp + b + ".html"
}
}
function getTzpj(b, a) {
if (parseInt(a) == 1) {
return "/stock/f10/invest/sh_" + b + ".xhtml"
} else {
return "/stock/f10/invest/sz_" + b + ".xhtml"
}
}
function reGetData() {
loadQuoteCommentList()
}
function search() {
sort = "ZDF";
pagenum = 1;
skip = 0;
pagesize = 30;
orderby = "desc";
loadQuoteCommentList()
}
function getDate(a) {
a = a.substring(0, 10).split("-");
return a[0] + "年" + a[1] + "月" + a[2] + "日晚间"
}
function getQuoteGSUrl(c, a) {
var b;
if (a == 1) {
b = qp+c + ".html"
} else {
if (a == 2) {
b = qp+ c + ".html"
} else {
b = "/stock/exdir.aspx?code=" + c
}
}
return b
}
function setStyle(e, d, b, a) {
var c = new String();
if (parseFloat(d) > parseFloat(b)) {
if (typeof(a) != "undefined") {
c = '<span class="red_color">' + formatNumber(e, digits) + a + "</span>"
} else {
c = '<span class="red_color">' + formatNumber(e, digits) + "</span>"
}
} else {
if (parseFloat(d) < parseFloat(b)) {
if (typeof(a) != "undefined") {
c = '<span class="green_color">' + formatNumber(e, digits) + a + "</span>"
} else {
c = '<span class="green_color">' + formatNumber(e, digits) + "</span>"
}
} else {
c = formatNumber(e, digits)
}
}
return c
}
function formatNumber(c, b) {
var a = new Number(c).toFixed(b);
return a
}
function getTradeDate(a) {
dt = a.substring(0, 10).split("-");
return "更新时间:" + dt[0] + "年" + dt[1] + "月" + dt[2] + "日晚间"
}
function isChinese(a) {
var b = /[^\u4e00-\u9fa5]/;
if (b.test(a)) {
return false
}
return true
};
评论列表