#!/usr/bin/phantomjs var page = require('webpage').create(), system = require('system'), args = system.args; if(args.length < 2){ console.log("Usage: " + args[0] + " ''"); phantom.exit(1); } page.open(args[1], function(status) { if (status !== 'success') { console.log('Unable to load the url!'); phantom.exit(); } else { window.setTimeout(function () { var elements = page.content.split("<"); for(e of elements){ if( e.includes("RY3") ){ if( e.includes("lh3") ){ var e = e.split('data-latest-bg="')[1]; e = e.split('"')[0]; console.log(e); break; } } } phantom.exit(); }, 2000); } });