Skip to content

Instantly share code, notes, and snippets.

@firedfox
Created August 10, 2012 09:49
Show Gist options
  • Select an option

  • Save firedfox/3313062 to your computer and use it in GitHub Desktop.

Select an option

Save firedfox/3313062 to your computer and use it in GitHub Desktop.
phantomjs retrieving text files
const TEXT_PREFIX = /<html><head><\/head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/;
const TEXT_SUFFIX = /<\/pre><\/body><\/html>/;
var page = require('webpage').create();
page.onLoadFinished = function() {
var content = page.content;
if (TEXT_PREFIX.test(content) && TEXT_SUFFIX.test(content)) {
content = content.replace(TEXT_PREFIX, '').replace(TEXT_SUFFIX, '');
};
console.log(content);
phantom.exit();
}
page.open('http://mehrdl.in/serverlist.text');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment