cli-scrape
Version:
screen scrape from command line with xpath or css selectors
7 lines • 2.13 kB
JavaScript
/*!
* @preserve Qwery - A Blazing Fast query selector engine
* https://github.com/ded/qwery
* copyright Dustin Diaz & Jacob Thornton 2012
* MIT License
*/
!function(){function j(a,b){var e=[];g=a.childNodes;for(c=0,d=g.length;c<d;c++)g[c].nodeType==1&&(!b||g[c].nodeName==b)&&e.push(g[c]);return e}function k(a,b,e,f){if(!e)return b[f-1]==a;for(c=f,d=b.length;e>0?c<=d:c>=1;c+=e)if(a==b[c-1])return!0;return!1}function l(a,b,c){return isFinite(c)?b[c-1]==a:c=="odd"?k(a,b,2,1):c=="even"?k(a,b,2,0):(h=i.exec(c))?k(a,b,h[2]?parseInt(h[1],10):parseInt(h[1]+"1",10),h[3]?parseInt(h[3].replace(/\s*/,""),10):0):!1}function m(a,b){if(a.nodeType===3||a.nodeType===4)return a.nodeValue;if(a.nodeType!==1&&a.nodeType!==9)return"";for(b="",a=a.firstChild;a;a=a.nextSibling)a.nodeType!==8&&(b+=a.textContent||a.innerText||m(a));return b}var a,b,c,d,e,f,g,h,i=/\s*((?:\+|\-)?(\d*))n\s*((?:\+|\-)\s*\d+)?\s*/;if(typeof module!="undefined"&&!0)a=require("qwery");else{if(typeof qwery=="undefined")return;a=qwery}b=a.pseudos,b.contains=function(a,b){return m(a).indexOf(b)!=-1},b.not=function(b,c){return!a.is(b,c)},b["nth-child"]=function(a,b){return!b||!(e=a.parentNode)?!1:l(a,j(e),b)},b["nth-last-child"]=function(a,b){return!b||!(e=a.parentNode)?!1:l(a,j(e).reverse(),b)},b["nth-of-type"]=function(a,b){return!b||!(e=a.parentNode)?!1:l(a,j(e,a.nodeName),b)},b["nth-last-of-type"]=function(a,b){return!b||!(e=a.parentNode)?!1:l(a,j(e,a.nodeName).reverse(),b)},b["first-child"]=function(a){return b["nth-child"](a,1)},b["last-child"]=function(a){return b["nth-last-child"](a,1)},b["first-of-type"]=function(a){return b["nth-of-type"](a,1)},b["last-of-type"]=function(a){return b["nth-last-of-type"](a,1)},b["only-child"]=function(a){return(e=a.parentNode)&&(g=j(e))&&g.length==1&&a==g[0]},b["only-of-type"]=function(a){return(e=a.parentNode)&&(g=j(e,a.nodeName))&&g.length==1&&a==g[0]},b.target=function(a){return a.getAttribute("id")==location.hash.substr(1)},b.checked=function(a){return a.checked},b.enabled=function(a){return!a.disabled},b.disabled=function(a){return a.disabled},b.empty=function(a){return!a.childNodes.length}}()