Skip to content

Instantly share code, notes, and snippets.

@agusibrahim
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agusibrahim/5b07e95c45f2ed5c03a9 to your computer and use it in GitHub Desktop.
Save agusibrahim/5b07e95c45f2ed5c03a9 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
<meta>
<author>Agus Ibrahim</author>
<description>Cek flight data</description>
<sampleQuery><![CDATA[
select * from {table} where dari='CKG' and ke='SRG']]></sampleQuery>
<documentationURL>http://www.wait-till-i.com/2009/11/16/using-yql-to-read-html-from-a-document-that-requires-post-data/</documentationURL>
</meta>
<bindings>
<select itemPath="" produces="JSON">
<urls>
<url>{url}</url>
</urls>
<inputs>
<key id="dari" type="xs:string" required="true" paramType="variable"/>
<key id="ke" type="xs:string" required="true" paramType="variable"/>
</inputs>
<execute>
<![CDATA[
var url="http://pontianaktiket.com/reservasi/step1";
var req = y.rest(url);
req.header('Accept-Encoding', 'gzip,deflate');
req.decompress(true);
var postdata='departure_city='+dari+'&arrival_city='+ke+'&radio-way=1&date-go=30-07-2015&date-back=30-07-2015&qty-adult=1&qty-child=0&qty-infant=0&btn-search=Search';
req.accept('text/html');
req.contentType("application/x-www-form-urlencoded");
var data=req.post(postdata).response.toString();
if(data.search('idCache')>0){
var hash=data.match(/[a-f0-9]{32}/)[0];
var dua=y.rest('http://pontianaktiket.com/reservasi/checker');
dua.header('Accept-Encoding', 'gzip,deflate');
dua.decompress(true);
data=dua.post('q='+dari+'-'+ke+'-1-0-0-30072015&a=AIR,EXP,KAL,TRI,LIO,SRI&c='+hash).response.toString();
}
response.object = '['+data+']';
]]>
</execute>
</select>
</bindings>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment