⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stock_v1.js

📁 最强的爬虫工程
💻 JS
📖 第 1 页 / 共 2 页
字号:
/**
 http://www.sinaimg.cn/cj/news/2007/1206/stock_v1.js
 TO DO : finance news stock keywords show
 */

var newspan = document.createElement("span");
newspan.id = "s_chart";
document.body.appendChild(newspan);

function show_quote(str,type,arrayPriceLast){
	var code = new Array();
	code=str.split(",");
	var l=code.length;
	if(arrayPriceLast){
		arrayPriceLast = arrayPriceLast.split(",");
	}
	arrayPrice = new Array();

	for(var i=0;i<l;i++){
		var a=eval("hq_str_"+code[i]);
		if (a == "")
		{
			continue;
		}
		var s=a.split(",");

		if(type=="stock"){
			var price=s[3];
			if(price==0)	price=s[2];
			var variable = price-s[2];	
			var percent=variable/s[2]*100;
			var time = s[30]+" "+s[31];
			percent = percent.toFixed(2);
			variable = variable.toFixed(2);
		}
		if(type=="forex"){
			var price=s[8];
			if(s[3] =="" || s[3]==0) {
				s[3]=0;
				percent = 0;
				variable = 0;
			}else{
				var variable = price-s[3];	
				variable = variable.toFixed(4);
				var percent=variable/s[3]*100;
				var time = s[0];
				percent = percent.toFixed(2);
			}
		}

		if(type=="futures"){
			var price=s[8] * 1;
			var variable = price-s[10];
			var percent=variable/s[10]*100;
			var time=s[1];
			price = code[i] == "au0806" ? price.toFixed(2) : Math.ceil(price);
			percent = percent.toFixed(2);
			variable = variable.toFixed(2);
		}

		if(variable>0){ 
			color="red";
		}else if(variable<0){
			color="green";
		}else{
			color="black";
		}

		var arrow="";
		if(arrayPriceLast){
			if (price>arrayPriceLast[i])
			{
				arrow="http://www.sinaimg.cn/cj/news_keyword/up_c.gif";
				//arrow = "<img src=http://image2.sina.com.cn/cj/news_keyword/up_c.gif style=\"border:0px\">";
				//arrow = "↓";
			}else if(price<arrayPriceLast[i]){
				arrow="http://www.sinaimg.cn/cj/news_keyword/down_c.gif";
				//arrow = "<img src=http://image2.sina.com.cn/cj/news_keyword/down_c.gif style=\"border:0px\">";
				//arrow = "↑";
			}else{
				//arrow = "<img src=http://image2.sina.com.cn/cj/news_keyword/blank.gif style=\"border:0px\">";
			}
		}

		arrayPrice[i] = price;
		if(arrow!=""){
			var P="<font color="+color+" style=\"BACKGROUND: url("+arrow+") no-repeat;padding-left:10px;\">"+price+"</font>";
		}
		else{
			var P="<font color="+color+" style=\"padding-left:10px;\">"+price+"</font>";
		}
		//var P="<font color="+color+">"+arrow+price+"</font>";
		var V="<font color="+color+">"+variable+"</font>";
		var C="<font color="+color+">"+percent+"%</font>";
		var Q = "("+P+","+V+","+C+",<a href=\"http://bar.sina.com.cn/bar.php?name="+code[i]+"\" style='text-decoration:none;' target='_blank'>吧</a>)";
		$('quote_'+code[i]).innerHTML=Q;
		

		var myImage = new setImg(type,code[i],time);
		myImage.showImage();
	
	}

	var url = "http://hq.sinajs.cn/list="+str;
	load_quote_data(url);
	setTimeout("show_quote('"+str+"','"+type+"','"+arrayPrice+"')",5000);
}

Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
};
function setImg(type, code,time){
	this.v= {};
	this.setvalue('code', code);
	this.setvalue('type', type);
	this.setvalue('time', time);
}
setImg.method('setvalue', function(key, value){
	this.v[key]=value;
	return this;
	}
);
setImg.method('getValue',function(k){return this.v[k];});
setImg.method('showImage',function(){
	code = this.getValue('code');
	type = this.getValue('type');
	var _self = this;
	alink = $(type+'_'+code);
	alink.onmouseover = function(evt){
			_code = _self.getValue('code');
			_type = _self.getValue('type');
			_time = _self.getValue('time');
			var Obj = $('s_chart');

			e=window.event?window.event:evt;
			objEvent = e.target || e.srcElement;
			x = objPosX(objEvent);
			y = objPosY(objEvent);

			Obj.style.position="absolute";
			Obj.style.left=x;
			Obj.style.top=y+16;
			Obj.style.visibility="visible";
			
			var code_a = _code.substr(0,2);
			var code_b = _code.substr(2,6);
			if(_type == "stock"){

				var CHART = "";
				CHART += "<form onsubmit=\"return to_quote(this);\" action=\"http://biz.finance.sina.com.cn/stock/stock_quote.php\" method='post' target='_blank'>";
				CHART += "<div class=\"s0\">";
				CHART += "<div class=\"s1\">";
				CHART += "<ul>";
				CHART += "<li><a href=\"http://vip.stock.finance.sina.com.cn/portfolio/qjia.php?symbol="+_code+"&ru="+window.location.href+"\" target='_self' title='点击加入我的自选股' style='color:#f00'>加入自选股</a></li>";
				CHART += "<li>┊</li>";
				CHART += "<li><a href=\"http://finance.sina.com.cn/realstock/"+code_a+"/"+code_b+"_notice.shtml\" target='_blank'>资讯</a></li>";
				CHART += "<li>┊</li>";
				CHART += "<li><a href=\"http://comment.finance.sina.com.cn/comment/skin/cj_stock.html?channel=gg&newsid="+code_a+"-"+code_b+"&style=1\" target='_blank'>论坛</a></li>";
				CHART += "<li>┊</li>";
				CHART += "<li><a href=\"http://biz.finance.sina.com.cn/stock/company/bulletin_list.php?code="+code_b+"\" target='_blank'>公告</a></li>";
				CHART += "</ul>";
				CHART += "</div>";
				CHART += "<div class=\"s2\">";
				CHART += "<input name=\"symbol\" type=\"text\" size=\"6\" style=\"font-size:12px;\"/>&nbsp;";
				CHART += "<select name=\"country\" type=text style=\"font-size:12px;\" disabled>";
						  CHART += "<option value=\"cn\" selected=\"selected\">大陆股市</option>";
						  CHART += "<option value=\"hk\">香港股市</option>";
						  CHART += "<option value=\"us\">美国股市</option>";
						  CHART += "<option value=\"tw\">台湾股市</option>";
				CHART += "</select>&nbsp;";
				CHART += "<input type=\"submit\" value=\"查询\" style=\"font-size:12px;\"/ name=\"Submit\">";
				CHART += "</div>";
				CHART += "<div>";
				CHART += "<div class=\"s5\">";
				CHART += "TIME: "+_time;
				CHART += "</div>";
				CHART += "<div class=s6><a href=\"http://finance.sina.com.cn/realstock/company/"+_code+"/nc.shtml\" target='_blank'><img src=\"http://fchart.sina.com.cn/newchart/small/b"+_code+".gif\" width=\"199\" height=\"125\" border=0></a></div>";
				CHART += "<div class=\"s3\">";
				CHART += "<ul>";
				CHART += "<li>·<a href=\"http://stock.finance.sina.com.cn/cgi-bin/stock/quote/quote.cgi?symbol="+code_b+"&country="+code_a+"\" target='_blank'>实时行情</a></li>";
				CHART += "<li>·<a href=\"http://bill.sina.com.cn/bill/trade_item.php?stock_code="+_code+"\" target='_blank'>成交明细</a></li>";
				CHART += "<li>·<a href=\"http://bill.sina.com.cn/bill/detail.php?stock_code="+_code+"&bill_size=40000\" target='_blank'>大单追踪</a></li>";
				CHART += "<li>·<a href=\"http://finance.sina.com.cn/stock/company/"+code_a+"/"+code_b+"/2.shtml\" target='_blank'>公司简介</a></li>";
				CHART += "<li>·<a href=\"http://finance.sina.com.cn/stock/company/"+code_a+"/"+code_b+"/3.shtml\" target='_blank'>股本结构</a></li>";
				CHART += "<li>·<a href=\"http://finance.sina.com.cn/stock/company/"+code_a+"/"+code_b+"/5.shtml\" target='_blank'>财务数据</a></li>";
				CHART += "</ul>";
				CHART += "</div>";
				CHART += "<div class=\"s4\">";
				CHART += "<a href=\"http://bar.sina.com.cn/bar.php?name="+_code+"\" style='text-decoration:none;' target='_blank'>吧</a>";
				CHART += "&nbsp;&nbsp;";
				CHART += "<a href=\"http://comment.finance.sina.com.cn/comment/skin/default.html?channel=cj&newsid=31-1-2989739\" target='_blank'>意见反馈</a>";
				CHART += "</div>";
				CHART += "</div>";
				CHART += "</form>";
			

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -