首先,你应该寻找在paging model(您的链接上面得到了压缩,所以我只是把它放在这里。
当您使用没有指定<execute></execute>
块分页,它将在使用查询字符串,在<url></url>
中指定的URL,只需要使用Flickr Photo Search Example,就必须在控制台打开诊断程序来查看URL中的更改,id
属性用于在查询中插入数字。在这里说明,寻呼部分看起来像这样:
<paging model="page">
<start id="page" default="0" />
<pagesize id="per_page" max="250" />
<total default="10" />
</paging>
例如,查询
select * from flickr.photos.search(10,20) where has_geo="true"`
使用的URL是http://api.flickr.com/services/rest/?method=flickr.photos.search&has_geo=true&page=1&per_page=30
。正如你所看到的,它实际上采取了page=1
,但要求per_page=30
并在内部截断了前10个结果,以便得到10的偏移量和总共20个结果。 YQL做到这一点的原因是因为所选模型是page
。
另一个例子,如果你试图这样做:
select * from flickr.photos.search(249,2) where has_geo="true"
YQL将同时检索...&page=1&per_page=250
和...&page=2&per_page=250
(我已经缩短了插图的URL)像预期的那样得到的结果。
如果您在<execute></execute>
部分中使用JavaScript,则也会在全局范围中定义分页变量。你可以看到这个在flickr.photos.astro OpenData Table中被使用。
我想应该回答你的问题,因为我看到on GitHub,你一直在研究如何使用XPath提取页面。
对于你的情况,你应该有这样的:
<paging model="page">
<start id="page" default="1" />
<pagesize id="per_page" max="10" />
<total default="10" />
</paging>
的per_page
将是你的内部查询,但它用于YQL来确定所需的查询。然后在你的JavaScript中可能会做类似的事情:
y.query(
"select * from html where [email protected]",
{url: "http://jetpackgallery.mozillalabs.com/jetpacks?page=" + page}
);