加上了“财经消息”小工具。。。但我感觉应该没人会看

纯用来提升逼格。。。数据来源 http://www.jin10.com/

附源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<audio id="ring" src="http://www.jin10.com/images/notice.wav"></audio>
<form>
<p style="font-size: 12px !important; margin: 0;"><label style="vertical-align:middle;"><input type="checkbox" id="economicsPlaySound" style="vertical-align:middle;">播放提示音</input></label>&nbsp;<label style="vertical-align:middle;"><input type="checkbox" id="economicsPlaySoundImportant" style="vertical-align:middle;">仅在有重要消息时提醒我</input></label></p>
</form>
<script type="text/javascript">
$(function() {
if ($.cookie("economics")>0) {
$("#economicsPlaySound").attr("checked","checked");
if ($.cookie("economics")==2) {
$("#economicsPlaySoundImportant").attr("checked","checked");
}
}
$("#economicsPlaySound").click(function() {
if (!this.checked) {
$.cookie("economics",0,{ expires: 30 });
document.getElementById("economicsPlaySoundImportant").checked=false;
} else {
$.cookie("economics",1,{ expires: 30 });
}
});
$("#economicsPlaySoundImportant").click(function() {
if (this.checked) {
$.cookie("economics",2,{ expires: 30 });
document.getElementById("economicsPlaySound").checked=true;
} else {
$.cookie("economics",1,{ expires: 30 });
}
});
});
</script>
<ul id="listarea">
</ul>
<style>
#listarea {
max-height: 350px;
overflow: auto;
}
#listarea li {
display: block;
line-height: 20px;
margin: 2px 0 10px 0 !important;
min-height: 20px;
}
#listarea li p {
margin: 0;
font-size: 12px !important;
}
#listarea li img {
padding-bottom: 0 !important;
}
</style>
<script src="http://cdn.jin10.com/socket.io/node_modules/socket.io-client/socket.io.js"></script>
<script type="text/javascript">
$("#listarea li").css("border-top","black 1px");
$("#listarea").parent().css({"background-color":"#ffffff","padding-bottom":"5px"});
var jin10 = io.connect("http://112.74.94.246:8080");
jin10.on('user message',function(msg){
msgbox(msg,true);
});
jin10.on('connect', function() {
jin10.emit('reg', "ok");
});
jin10.on('disconnect', function() {
$("#listarea").prepend("<li><p style=\"font-weight: bold; color: red;\">Connection Lost. Pleace refresh this page.</p></li>");
});
var template1 = "<!-- {pic} {have} --><li{color}><small>{time}</small><p>{more}</p><p>{content}</p></li>";

var template2 = "<!-- {pic} --><li{color}><small>{time}</small><p>{mingcheng}</p>前值:{qianzhi} 预期:{yuqi},公布:{gongbu}</p><p>{xingji} 星数据,影响金银:{yingxiang}</p></li>";

function msgbox(str){
console.log(str);
if (str.match("金十贵金属多空投票") || str.match("1442406496.jpg")) {
return;
};
var arrmp = str.split("#");
var type = arrmp[0];
var im = arrmp[1];
var sj = arrmp[2];
var nr = arrmp[3];
var a4 = arrmp[4];
var a5 = arrmp[5];
var a6 = arrmp[6];
var a7 = arrmp[7];
var a8 = arrmp[8];
var a9 = arrmp[9];
var addtext = "";

if (arguments[1]) {
var playSound=getCookie("economics");
if (playSound==1 || (playSound==2 && im==0)) {
document.getElementById("ring").play();
}
}

if(type == "0") {
sj = sj.substr(11,8);
if(im == "0"){
addtext = template1.replace("{color}"," style=\"color:red; font-weight: bold;\"").replace("{pic}","importantnews.png").replace("{time}",sj).replace("{content}",nr);
} else {
addtext = template1.replace("{color}","").replace("{pic}","nomarlnews.png").replace("{time}",sj).replace("{content}",nr);
}
if(a4.length > 5 || a5.length >5 || a6.length >5) {
//have url pic video
if(a4.length > 5 && a5.length > 5 && a6.length > 5) {
addtext = addtext.replace("{have}","have_url_pic_video");
} else if((a4.length > 5 && a5.length > 5) || (a5.length > 5 && a6.length > 5)) {
addtext = addtext.replace("{have}","have_url_pic");
} else if(a4.length > 5 && a5.length > 5) {
addtext = addtext.replace("{have}","have_no_pic");
} else if(a6.length > 5 && a4.length < 5 && a5.length < 5) {
addtext = addtext.replace("{have}","have_pic");
}

addtext = addtext.replace("{more}","{more2}");

if(a4.length > 5) {
addtext = addtext.replace("{more2}","<a href=\""+a4+"\" target=\"_blank\">链接戳这里<\/a>{more3}");
} else {
addtext = addtext.replace("{more2}","{more3}");
}

if(a5.length > 5) {
addtext = addtext.replace("{more3}","<a class=\"youtube\" href=\""+a5+"\" target=\"_blank\"><img src=\"http://www.jin10.com/oem\/images\/video2.png\" style=\"padding-bottom:5px;\" border=\"0\" /><\/a>{more4}");
} else {
addtext = addtext.replace("{more3}","{more4}");
}

if(a6.length > 5) {
addtext = addtext.replace("{more4}","<a href=\"http:\/\/image.jin10.com\/"+a6.replace("_lite","")+"\" target=\"_blank\"><img src=\"http:\/\/image.jin10.com\/"+a6+"\" width=\"50\" style=\"padding-bottom:5px; max-height:85px;\" border=\"0\" \/><\/a>");
} else {
addtext = addtext.replace("{more4}","");
}


} else {
addtext = addtext.replace("{more}","");
}

$("#listarea").prepend(addtext);
} else if(type == "1") {
im = im.substr(0,5);
if(a6 >= 3) {
a7.replace("2","");
addtext = template2.replace("{color}"," style=\"color:red; font-weight: bold;\"").replace("{pic}","importantdata.png").replace("{time}",a8.substr(11,8)).replace("{shijian}",im).replace("{mingcheng}",sj).replace("{qianzhi}",nr).replace("{yuqi}",a4).replace("{gongbu}",a5).replace("{xingji}",a6).replace("{yingxiang}",a7);
} else {
addtext = template2.replace("{color}","").replace("{pic}","nomarldata.png").replace("{time}",a8.substr(11,8)).replace("{shijian}",im).replace("{mingcheng}",sj).replace("{qianzhi}",nr).replace("{yuqi}",a4).replace("{gongbu}",a5).replace("{xingji}",a6).replace("{yingxiang}",a7);
}

$("#listarea").prepend(addtext);
}//else if(type == "1")
}//function msgbox(str){
var newsData=<?php
function curl_get_contents($url,$timeout=5,$method='get',$post_fields=array()) { //封装 curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
if ($method=='post') {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_fields);
}
$output = curl_exec($ch);
curl_close($ch);
return $output;
}

$content=preg_replace("/\n|\s{3,}/", "",curl_get_contents("http://www.jin10.com/jin10.com.html"));
preg_match_all("/<div class=\"listline.*?\">(.*?)<!-- listline end -->/is",$content,$news);
$newArray=array();
for ($i=0;$i<50;$i++) {
$new=$news[0][$i];
if (strpos($new,"class=\"data\"")) {
$type=1;
} else {
$type=0;
}
$im="";
$sj="";
$nr="";
$a4="";
$a5="";
$a6="";
$a7="";
$a8="";
$a9="";
if ($type==0) {
preg_match_all("/<div class=\"doany\">(.*?)<\/div>/is", $new, $tmpMore);
if ($tmpMore[1][0]!=="") {
if (preg_match_all("/<a href=\"(.*?)\" target=\"_blank\"><img src=\"http:\/\/www.jin10.com\/images\/website2.png\" style=\"padding-bottom:5px;\" border=\"0\" \/><\/a>/", $tmpMore[1][0],$a4Tmp)) {
$a4=$a4Tmp[1][0];
}
if (preg_match_all("/<a class=\"youtube\" href=\"(.*?)\" target=\"_blank\"><img src=\"http:\/\/www.jin10.com\/images\/video2.png\" style=\"padding-bottom:5px;\" border=\"0\" \/><\/a>/", $tmpMore[1][0],$a5Tmp)) {
$a5=$a5Tmp[1][0];
}
if (preg_match_all("/<img src=\"http:\/\/image.jin10.com\/(.*?)\" width=\"50\" style=\"padding-bottom:5px; max-height:85px;\" border=\"0\" \/>/", $tmpMore[1][0],$a6Tmp)) {
$a6=$a6Tmp[1][0];
}
}
if (strpos($new, "listline important")) {
$im=0;
} else {
$im=1;
}
preg_match_all("/<div class=\"time\">(.*?)<\/div>/", $new, $sjArr);
$sj="0000-00-00 ".$sjArr[1][0];
preg_match_all("/<p class=\"text\">(.*?)<\/p>/", $new, $nrArr);
$nr=$nrArr[1][0];
} else {
preg_match_all("/<div class=\"dname\">(.*?)<\/div>/", $new, $sjArr);
$sj=$sjArr[1][0];
preg_match_all("/<div class=\"preview\">前值:(.*?) 预期:(.*?)<\/div>/", $new, $nra4Arr);
$nr=$nra4Arr[1][0];
$a4=$nra4Arr[2][0];
preg_match_all("/<div class=\"actual\">实际:(.*?)<\/div>/", $new, $a5Arr);
$a5=$a5Arr[1][0];
preg_match_all("/<img src=\"oem\/images\/star\/(.*?).png\" width=\"20\" height=\"34\" border=\"0\" \/>/", $new, $a6Arr);
$a6=$a6Arr[1][0];
preg_match_all("/<div class=\"updown\"><img src=\"oem\/images\/updown\/(.*?).png\" width=\"82\" height=\"24\" border=\"0\" \/><\/div>/", $new, $a7Arr);
$a7=str_replace("2", "", $a7Arr[1][0]);
preg_match_all("/<div class=\"time isdata\">(.*?)<\/div>/", $new, $a8Arr);
$a8="0000-00-00 ".$a8Arr[1][0];
preg_match_all("/<img src=\"oem\/images\/flag\/(.*?).png\" width=\"40\" height=\"40\" border=\"0\" \/>/", $new, $a9Arr);
$a9=$a9Arr[1][0];
}
$newArray[]=implode("#",array($type,$im,$sj,$nr,$a4,$a5,$a6,$a7,$a8,$a9));
}
echo json_encode(array_reverse($newArray));
?>;
for (var i=0;i<newsData.length;i++) {
msgbox(newsData[i]);
}
</script>