Skip to content

Instantly share code, notes, and snippets.

@brettwooldridge
Created May 29, 2014 02:53
Show Gist options
  • Save brettwooldridge/f377992ab3d468db374f to your computer and use it in GitHub Desktop.
Save brettwooldridge/f377992ab3d468db374f to your computer and use it in GitHub Desktop.
imac.js
var page = require('webpage').create();
page.open('http://store.apple.com/jp/browse/home/specialdeals/mac/imac/27', function(status) {
page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function(status) {
page.onConsoleMessage = function (msg) { console.log(msg); };
page.evaluate(function() {
$( "td.specs" ).each( function(index) {
var pattern = /(i5|i7)[\s\S]*(8GB|16GB|32GB)[\s\S]*(Fusion)/mi;
var m = $(this).text().match(pattern);
if (m != null && m.length > 0) {
console.log("Match: " + m[1] + " " + m[2] + " " + m[3]);
}
else {
console.log("Nope.");
}
});
});
phantom.exit()
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment