diff options
Diffstat (limited to 'discover-url.coffee')
-rw-r--r-- | discover-url.coffee | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/discover-url.coffee b/discover-url.coffee new file mode 100644 index 0000000..cf8627d --- /dev/null +++ b/discover-url.coffee @@ -0,0 +1,21 @@ +system = require 'system' +[_, listing_page, filename, username, password] = system.args + +util = require './util' +page = util.page + +page.open listing_page, (status) -> + util.log "Open listing page: #{status}" + util.handle_login_captcha -> + util.log 'Searching URLs...' + url = page.evaluate (filename) -> + # Characters in filename may need to be escaped for use in a selector + found = document.querySelector ".downloads.linux a[href*='#{filename}']" + found and found.getAttribute('href') + , filename + util.log "Found URL: #{url}" + if url + system.stdout.writeLine url + phantom.exit() + , username, password + |