Skip to content

wreckvsfaraday

BSD-3-Clause 3 7 383
226.6 thousand (month) Aug 06 2011 18.1.0(6 months ago)
5,702 7 39 MIT
Dec 19 2009 4.6 million (month) 2.9.2(27 days ago)

Wreck is an HTTP client library for Node.js. It provides a simple, consistent API for making HTTP requests, including support for both the client and server side of an HTTP transaction.

Wreck is a very minimal but stable as it's part of Hapi web framework project. For web scraping, it doesn't offer required features like proxy configuration or http2 support so it's not recommended.

Faraday is a Ruby gem that provides a simple and flexible interface for making HTTP requests. It allows you to create a Faraday connection object, which you can use to send requests and receive responses.

Faraday abstracts away the details of the underlying HTTP client library, so you can use it with different libraries such as Net::HTTP, HTTPClient, typhoeus and others.

Since Faraday can adapt many other HTTP clients it's very popular choice in web scraping.

Example Use


const Wreck = require('wreck');

// get request
Wreck.get('http://example.com', (err, res, payload) => {
    if (err) {
        throw err;
    }
    console.log(payload.toString());
});

// post request
const options = {
    headers: { 'content-type': 'application/json' },
    payload: JSON.stringify({ name: 'John Doe' })
};

Wreck.post('http://example.com', options, (err, res, payload) => {
    if (err) {
        throw err;
    }
    console.log(payload.toString());
});
# GET requests
response = Faraday.get('http://httpbingo.org')
put response.status
put response.headers
put response.body

# or use a persistent client session:
conn = Faraday.new(
  url: 'http://httpbin.org/get',
  params: {param: '1'},
  headers: {'Content-Type' => 'application/json'}
)

# POST requests
response = conn.post('/post') do |req|
  req.params['limit'] = 100
  req.body = {query: 'chunky bacon'}.to_json
end

Alternatives / Similar


Was this page helpful?