forked from yql/yql-tables
/
YVoices.featuredarticles.xml
57 lines (57 loc) · 2.17 KB
/
YVoices.featuredarticles.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd" securityLevel="any">
<meta>
<author>HOUYHNHNM</author>
<description> Gets the list of featured articles by a Yahoo Voices contributor from their frontpage</description>
<documentationURL></documentationURL>
<sampleQuery>select * from {table} where query="http://contributor.yahoo.com/user/270293/carol_rucker.html"</sampleQuery>
<sampleQuery>select * from {table} where query="http://contributor.yahoo.com/user/1167189/r_salley.html"</sampleQuery>
</meta>
<bindings>
<select itemPath="" produces="XML">
<inputs>
<key id='query' type='xs:string' paramType='variable' required="true"/>
</inputs>
<execute>
<![CDATA[
var str1="select * from html where url=\"";
var str2="\" and xpath='//div[@class=\"sliding_feature\"]/div[@class=\"sliding_mask\"]/div[@class=\"sliding_content\"]/div[@class=\"item\"]'";
var yqlquery=y.query(str1+query+str2);
var yqlresults=yqlquery.results;
var yqlcounter=parseInt(yqlresults.div.length());
var index=0;
var xmlret=new XML();
xmlret=<root><count>{yqlcounter}</count></root>;
while(index<yqlcounter)
{
if(yqlresults.div[index].span.length()>0)
{
if((yqlresults.div[index].a)&&(yqlresults.div[index].div)&&(yqlresults.div[index].div.img))
{
xmlret.root+=<node>
<title>{yqlresults.div[index].span[0].text()}</title>
<description>{yqlresults.div[index].span[1].text()}</description>
<link>{yqlresults.div[index].a.@href}</link>
<thumbnail>{yqlresults.div[index].div.img.@src}</thumbnail>
</node>
}
}
else
{
if((yqlresults.div[index].a)&&(yqlresults.div[index].a.span[0])&&(yqlresults.div[index].a.span[1]))
{
xmlret.root+=<node>
<title>{yqlresults.div[index].a.span[0].text()}</title>
<description>{yqlresults.div[index].a.span[1].text()}</description>
<link>{yqlresults.div[index].a.@href}</link>
</node>
}
}
index++;
}
response.object=xmlret;
]]>
</execute>
</select>
</bindings>
</table>