New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

requester

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

requester

swiss army knife for requests

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
175
increased by348.72%
Maintainers
1
Weekly downloads
 
Created
Source

node-requester

A simple network request helper that is geared towards crawling. (a few keywords GZIP, XML, JSON, PROXIES)

installation

$ npm install requester

super simple to use

var Requester = require('requester'),
	requester = new Requester();

requester.get(/* URL */, function (body) {
	console.log(body)
});

requester.get(/* URL */, /* REQUEST_OBJECT */, function (body) {
	console.log(body)
});

initialization

var Requester = ('requester');

var requester = new Requester({
	cookies: {},
	headers: {},
	timeout: 4000,
	retries: 3,
	encoding 'utf8',
	// didRequestFail: null, (this has its own section)
	// signRequest: null, (this has its own section)
	dataType: 'RAW' // JSON or XML,
	auth: {username: 'username', password: 'password'}, // basic auth for all requests
	proxies: [{ip: '127.0.0.1', port: 1337}, {ip: '127.0.0.2', port: 1337}, {ip: '127.0.0.3', port: 1337}] // rotating proxy array
});

if you initialize the request object with any of the above properties every request will default to those settings, you can over ride them on a per request basis

var options = {
	encoding: 'binary',
	proxy: {ip: '127.0.0.1', port: 1337},
	data: {foo: 'bar'},
	cookies: {foo: 'bar'},
	auth: {username: 'username', password: 'password'} // basic auth for request
};

requester.get(/* URL */, options, function (body) {
	console.log(body)
});

request objects

they support the following properties

  • {Object} data
  • {String} dataType
  • {Object} headers
  • {Object} cookies
  • {Object} proxy
  • {Object} auth
  • {String} encoding
  • {Number} timeout
  • {Number} retries
  • {Function} didRequestFail
  • {Function} signRequest

request signatures

you can create a custom request signature function like this

var qs = require('querystring');

var requester = new Requester({
	signRequest: function (data) {
		// do something with the data
		return qs.stringify(data);
	}
});

posting

requester.post(/* URL */, {data: {foo: 'bar', bar: 'foo'}}, function (body) {
	console.log(body)
});

multipart

the multipart request works a little different, in the data object you can prefix a values key with '@' like this

requester.multipart(/* URL */, {data: {'@file': /* FILEPATH */, '@file2': /* FILEPATH */, bar: 'foo'}}, function (body) {
	console.log(body)
});

this will create a multipart request and upload files

Keywords

FAQs

Package last updated on 29 Oct 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc