phantomjs rasterize has problems with url parameters -
i'm on windows machine using standard commandline tool , using phantomjs , modified rasterize.js code. problem have when pass url, http://time.com/3274245/e-cigarettes-debate/?utm_source=feedburner&utm_medium=feed&utm_campaign=feed:+time/topstories+(time:+top+stories). i've redirected standardoutput , standarderror , here's above url.
standardoutput
usage: rasterize.js url filename [paperwidth*paperheight|paperformat] [zoom] paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "a4", "letter" standarderrror
'utm_source' not recognized internal or external command, operable program or batch file. 'utm_medium' not recognized internal or external command, operable program or batch file. 'utm_campaign' not recognized internal or external command, operable program or batch file. so question is, there way resolve problem parameters in url?
please let me know if there information missing or if needs clarified.
i'll add modified rasterize.js below.
var page = require('webpage').create(), system = require('system'), address, output, size; page.settings.useragent = 'mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:31.0) gecko/20100101 firefox/31.0'; if (system.args.length < 3 || system.args.length > 5) { console.log('usage: rasterize.js url filename [paperwidth*paperheight|paperformat] [zoom]'); console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "a4", "letter"'); phantom.exit(1); } else { address = system.args[1]; output = system.args[2]; page.viewportsize = { width: 1200, height: 1200 }; if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") { size = system.args[3].split('*'); page.papersize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' } : { format: system.args[3], orientation: 'portrait', margin: '1cm' }; } if (system.args.length > 4) { page.zoomfactor = system.args[4]; } page.open(address, function (status) { if (status !== 'success') { console.log('unable load address!'); phantom.exit(); } else { window.settimeout(function () { page.render(output); phantom.exit(); }, 10000); } }); }
in windows cmd need use quotes around parameters might have special characters. = candidate when breaks.
phantomjs rasterize.js "http://time.com/..." time.png for page might need disable web security:
phantomjs --web-security=false rasterize.js "http://time.com/..." time.png
Comments
Post a Comment