Skip to content

Instantly share code, notes, and snippets.

@niraj-shah niraj-shah/postReq.js
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.