Created
March 21, 2009 20:37
-
-
Save youpy/82974 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* appjet:version 0.1 */ | |
import('lib-html-xpath'); | |
import('lib-json'); | |
import("lib-uri"); | |
function get_main() { | |
print(P(A({ | |
href: '/pagelinks?url=' + encodeURIComponent('http://google.com/') | |
}, appjet.appName))); | |
} | |
function get_pagelinks() { | |
page.setMode("plain"); | |
var url = request.params.url; | |
if(!url) { | |
return; | |
} | |
var hrefs = xget(url, '//*[@href]'); | |
var uri = new URI(hrefs.base ? hrefs.base[0].href : url); | |
var links = [].concat(hrefs.a).map(function(link) { | |
if(link.href) { | |
return { | |
link: uri.resolveLink(link.href).toString() | |
}; | |
} | |
}); | |
print(raw(JSON.stringify(links))); | |
} | |
dispatch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment