问题
I am trying to fetch content from following web page
http://www.mfinante.ro/infocodfiscal.html?cod=10376836
My code is
var fetchString="www.mfinante.ro/infocodfiscal.html?cod=10376836";
var response = UrlFetchApp.fetch(fetchString);
When I view page source of above link it shows correct content but urlfetch showing different content.
In other words view source of above page shows html but urlfetch shows only javascript.
view-source:http://www.mfinante.ro/infocodfiscal.html?cod=10376836
view source behaving differently sometime shows html sometimes javascript.
回答1:
Use PhantomJS and the following js code:
var system = require('system');
var page = require('webpage').create();
page.open(system.args[1], function(status) {
setTimeout(function(){
console.log(page.plainText);
phantom.exit();
}, 10000);
});
In linux:
phantomjs visit.js http://www.mfinante.ro/infocodfiscal.html?cod=5066472
In Windows:
phantomjs.exe visit.js http://www.mfinante.ro/infocodfiscal.html?cod=5066472
来源:https://stackoverflow.com/questions/31452272/google-app-script-urlfetch-not-giving-html-output-but-javascript-ouput