Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add Submarino tables.

  • Loading branch information...
commit 5942cb89f120ebb31947776b56aecd60a15e2e74 1 parent ac06077
@rainerborene rainerborene authored
View
52 brazil/submarino/brazil.submarino.busca.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <author>Rainer Borene</author>
+ <description>Pesquisa na lista de produtos vendidos na Submarino</description>
+ <documentationURL></documentationURL>
+ <sampleQuery>select * from {table} where query="ipod" and offset="20" and limit="20"</sampleQuery>
+ </meta>
+ <bindings>
+ <select produces="XML">
+ <urls>
+ <url>http://www.submarino.com.br/busca</url>
+ </urls>
+ <inputs>
+ <key id="q" as="query" type="xs:string" paramType="query" required="true" />
+ <key id="offset" type="xs:string" paramType="query" required="false" default="0" />
+ <key id="limit" type="xs:string" paramType="query" required="false" default="20" />
+ </inputs>
+ <execute><![CDATA[
+ var results = [];
+ var data = request.accept('text/html').get().response;
+ var products = y.xpath(data, "//ul[@id='ul_product_list1']/li/div");
+ var total_entries = y.xpath(data, "//div[@class='bottomPageList']/ul[@class='results']/li/p/text()");
+
+ for each (var item in products) {
+ results.push({
+ image: y.xpath(item, "//a[contains(@class, 'link')]/img/@src"),
+ title: y.xpath(item, "//span[@class='name entry-title']/strong/text()"),
+ description: y.xpath(item, "//span[@class='description']/text()")
+ });
+ }
+
+ if (results.length) {
+ var output = <products></products>;
+
+ for (item in results) {
+ output.node += <entry>
+ <title>{results[item].title}</title>
+ <description>{results[item].description}</description>
+ <image>{results[item].image}</image>
+ </entry>;
+ }
+
+ output.@items = total_entries.match(/\d+$/)[0];
+ }
+
+ response.object = output;
+ ]]>
+ </execute>
+ </select>
+ </bindings>
+</table>
View
38 brazil/submarino/brazil.submarino.produto.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
+ <meta>
+ <author>Rainer Borene</author>
+ <description>Retorna informações sobre o produto</description>
+ <documentationURL></documentationURL>
+ <sampleQuery>select * from {table} where id="21620477" dep="10"</sampleQuery>
+ </meta>
+ <bindings>
+ <select produces="XML">
+ <urls>
+ <url>http://www.submarino.com.br/produto/{dep}/{id}/</url>
+ </urls>
+ <inputs>
+ <key id="dep" type="xs:string" paramType="path" required="true" />
+ <key id="id" type="xs:string" paramType="path" required="true" />
+ </inputs>
+ <execute><![CDATA[
+ var data = request.accept('text/html').get().response;
+ var images = y.xpath(data, "//ul[@class='listThumbsProduct']/li/a/img/@src");
+ var entry = {};
+
+ entry.title = y.xpath(data, "//div[@class='boxProductName']/h1/text()").toString();
+ entry.price = y.xpath(data, "//ul[@class='listPriceInfo']/li/strong[@class='for']/span/text()").toString();
+ entry.description = y.xpath(data, "//div[@id='C1']/ul/li").toString();
+ entry.images = { image: [] };
+
+ for each (var image in images) {
+ entry.images.image.push(image.toString());
+ }
+
+ response.object = y.jsonToXml(entry);
+ ]]>
+ </execute>
+ </select>
+ </bindings>
+</table>
+
Please sign in to comment.
Something went wrong with that request. Please try again.