wreckvsexcon
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.
Excon is a Ruby library for making HTTP requests. It is designed to be fast and efficient, and is often used as a building block for other Ruby libraries and frameworks.
One of the main features of Excon is its support for persistent connections, which allows it to reuse the same connection for multiple requests, reducing the overhead of establishing a new connection for each request.
Excon also supports streaming requests and responses, which allows you to read or write data to the server incrementally, without having to load the entire response into memory at once.
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());
});
require 'excon'
# GET requests
response = Excon.get('https://jsonplaceholder.typicode.com/posts/1')
puts response.body
puts response.status
puts response.headers
# POST requests
response = Excon.post('https://jsonplaceholder.typicode.com/posts',
:body => { :title => 'foo', :body => 'bar', :userId => 1 }.to_json,
:headers => { 'Content-Type' => 'application/json' } )
puts response.body