From 23fcf1acc62e0f32f479c12c1916b2b1dd922199 Mon Sep 17 00:00:00 2001 From: Yaohan Chen Date: Tue, 1 Apr 2014 01:21:59 -0400 Subject: Support the new Humble Bundle page Use PhantomJS to handle the dynamically generated page and captchas. Add options to specify the location of PhantomJS scripts and configuration file. Update README on requirements, usage, and debugging information. Update CHANGELOG. --- discover-url.coffee | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 discover-url.coffee (limited to 'discover-url.coffee') 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 + -- cgit v1.2.3-70-g09d2