-
Notifications
You must be signed in to change notification settings - Fork 1
/
spored.tv-yql.html
50 lines (50 loc) · 2.16 KB
/
spored.tv-yql.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>spored.tv - dynamic content with YQL</title>
<script type="text/javascript">
function cbspored_tv(data) {
"use strict";
var c = document.getElementById("spored"),
html = "",
i,
len,
d,
r,
TV,
TVlink,
title,
desc,
hour;
if (data.error) {
c.innerHTML = data.error.description;
return;
}
r = data.query.results.div;
for (i = 0, len = r.length; i < len; i += 1) {
d = r[i];
if (d.h3) {
TV = d.a.title;
TVlink = d.a.href;
if (i > 0) {
html += "<br>";
}
html += '<a href="' + TVlink + '">' + TV + '<\/a><br>';
} else {
hour = d.span.content || d.span;
title = (d.a && d.a[0].content) || d.p || '';
desc = d.div ? d.div.p : '';
html += "<em>" + hour + "</em> <strong>" + title + "</strong> " + desc + "<br>";
}
}
c.innerHTML = html;
}
</script>
</head>
<body>
<div id="spored"></div>
<!-- select * from html where url="http://www.spored.tv/" and xpath="//div[@id='Content']/div/div" -->
<script type="text/javascript" src="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fwww.spored.tv%2F%22%20and%20xpath%3D%22%2F%2Fdiv%5B%40id%3D'Content'%5D%2Fdiv%2Fdiv%22&format=json&callback=cbspored_tv&diagnostics=false"></script>
</body>
</html>