Himanshu Tiwari
Himanshu Tiwari

Reputation: 107

Google App Script UrlFetch not giving HTML output but JavaScript ouput

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.

Upvotes: 0

Views: 1546

Answers (1)

UnPatrion
UnPatrion

Reputation: 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

Upvotes: -1

Related Questions