HTTP.fetchWebpageHtml()

Fetch the HTML from a web page.

Usage

Hover over inputs/exits for more info.

var HTTP = require('machinepack-http');


// Fetch the HTML from a web page.

HTTP.fetchWebpageHtml({

url: 'http://www.example.com/games/search?q=minecraft&page=14',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// A non-2xx status code was returned from the server.

non200Response: function (result) {

 

},

// Unexpected connection error: could not send or receive HTTP request.

requestFailed: function () {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

url required

The URL of the web page to fetch.

'http://www.example.com/games/search?q=minecraft&page=14'

Exits

error

An unexpected error occurred.

non200Response

A non-2xx status code was returned from the server.

{ statusCode: 404,
  headers: {},
  body: '...[{"maybe some JSON": "like this"}]  (but could be any string)' }
requestFailed

Unexpected connection error: could not send or receive HTTP request.

success

OK.

'<html><body><h1>Hello world</h1></body></html>'