Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Last active August 29, 2015 14:17
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save niraj-shah/e3ae239194d982e938f2 to your computer and use it in GitHub Desktop.
NodeJS Example of POST
// include the libraries we need
var request = require('request');
var cheerio = require('cheerio');
// set some defaults
req = request.defaults({
jar: true, // save cookies to jar
rejectUnauthorized: false,
followAllRedirects: true // allow redirections
});
// POST data then scrape the page
req.post({
url: "http://www.example.com/",
form: { 'foo': 'bar' },
headers: {
'User-Agent': 'Super Cool Browser' // optional headers
}
}, function(err, resp, body) {
// load the html into cheerio
var $ = cheerio.load(body);
// do something with the page here
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment