Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Uniqhtt is a versatile Node.js library designed for handling HTTP requests and responses with advanced cookie management, HTML parsing, and CSS processing capabilities. It leverages powerful tools like jsdom, fetch-cookie, and postcss to provide a robust
Welcome to Uniqhtt, a powerful and versatile Node.js library designed to handle advanced HTTP requests, response processing, and web automation. This library stands out with its comprehensive support for cookie management, HTML parsing, CSS transformation, and Wget-like recursive website cloning features. Uniqhtt provides a solid solution for web scraping, data extraction, and automation tasks, making it a valuable tool for developers working in diverse environments ranging from Node.js to serverless platforms and browsers.
Uniqhtt brings a suite of robust features to empower your HTTP requests and web automation workflows:
tough-cookies
for sophisticated session handling, making it easy to manage and persist cookies.jsdom
, enabling developers to parse and manipulate HTML structures with ease.postcss
.To install Uniqhtt, use npm or yarn:
npm install uniqhtt
Or, using yarn:
yarn add uniqhtt
This will install Uniqhtt along with its dependencies, including jsdom
, fetch-cookie
, and postcss
.
Uniqhtt provides a simplified API for making HTTP requests similar to popular libraries like Axios, while offering advanced features for handling cookies, scraping, and cloning websites.
const uniqhtt = require('uniqhtt');
uniqhtt.get('https://example.com')
.then(response => {
console.log(response.data); // HTML or JSON response
})
.catch(error => {
console.error('Error occurred:', error);
});
uniqhtt.post('https://example.com/login', {
data: {
username: 'user',
password: 'pass',
},
cookies: true
})
.then(response => {
console.log('Login successful:', response.data);
})
.catch(error => {
console.error('Login failed:', error);
});
For a comprehensive guide on using Uniqhtt, keep reading the detailed documentation below.
Uniqhtt supports all major HTTP methods, enabling it to cover a wide range of use cases for interacting with RESTful APIs or handling custom HTTP interactions.
Uniqhtt's request options mirror the popular Axios-like structure, making it easy for developers familiar with other libraries to integrate.
GET
).username
and password
).json
, text
, arraybuffer
, etc.).uniqhtt.get('https://api.example.com/data', {
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
}
})
.then(response => console.log(response.data));
For secure communication, Uniqhtt offers flexible HTTPS options to handle advanced scenarios, such as mutual TLS.
Uniqhtt integrates tough-cookies for advanced cookie handling, making it a great tool for web scraping or interacting with stateful HTTP sessions.
uniqhtt.setCookies([{ name: 'session', value: 'abc123', domain: 'example.com' }]);
uniqhtt.get('https://example.com/dashboard')
.then(response => {
console.log('Dashboard data:', response.data);
});
Uniqhtt can emulate Wget functionality, enabling recursive website downloading, link rewriting, and local storage of complete websites.
uniqhtt.clone('https://example.com', {
recursive: true,
level: 3,
convertLinks: true,
outputDirectory: './website_clone'
})
.then(() => console.log('Website cloned successfully!'))
.catch(error => console.error('Error while cloning website:', error));
Uniqhtt supports various storage options to fit different needs for persisting downloaded content.
bucket
, region
, accessKeyId
, and secretAccessKey
.host
, port
, user
, and password
.Uniqhtt offers several advanced features to enhance its capabilities:
createUniqhtt()
function.Uniqhtt provides comprehensive error handling, ensuring developers have access to all necessary details when something goes wrong:
RequestError
might include details about the failed HTTP request, while a ResponseError
could provide insight into the server response that caused the failure.uniqhtt.get('https://example.com/data', {
retryAttempts: 3, // Retry up to 3 times
retryDelay: 1000 // Wait 1 second between retries
})
.then(response => {
console.log('Data received:', response.data);
})
.catch(error => {
if (error.isRetryError) {
console.error('Request failed after multiple retries:', error);
} else {
console.error('An unexpected error occurred:', error);
}
});
Uniqhtt is fully compatible with TypeScript, offering a strong typing system that enhances developer experience by catching errors at compile time and providing better IntelliSense support. TypeScript definitions are bundled with the package, ensuring you don’t need to install additional typings.
import uniqhtt from 'uniqhtt';
uniqhtt.get('https://example.com')
.then((response: uniqhtt.UniqhttResponse<string>) => {
console.log(response.data); // Data typed as string
})
.catch((error: uniqhtt.UniqhttError) => {
console.error('Error occurred:', error.message);
});
By utilizing TypeScript, Uniqhtt ensures that developers can take full advantage of type safety, making it easier to spot errors early in the development process and ensuring higher quality code.
We welcome contributions to Uniqhtt! Whether you're fixing bugs, improving documentation, or adding new features, your input is valuable.
Before submitting, make sure your code passes all tests and linting checks to ensure consistency and quality.
Uniqhtt is a comprehensive, advanced HTTP client for Node.js, offering a range of features designed to handle everything from basic HTTP requests to complex web scraping and automation tasks. Its support for cookie management, recursive website cloning, parallel downloads, flexible storage, and advanced error handling makes it a powerful tool for developers working on a wide variety of projects.
Whether you're building a scraping engine, an API client, or an automated testing tool, Uniqhtt provides the tools you need in a simple, highly customizable package. With features like TypeScript support, retry mechanisms, and seamless cookie handling, Uniqhtt is designed to handle modern web interactions efficiently and securely.
For more detailed examples, head over to the [official documentation] and start exploring all that Uniqhtt has to offer!
Happy coding! 🎉
Uniqhtt is released under the MIT License. See the LICENSE file for more details.
FAQs
Uniqhtt is a versatile Node.js library designed for handling HTTP requests and responses with advanced cookie management, HTML parsing, and CSS processing capabilities. It leverages powerful tools like jsdom, fetch-cookie, and postcss to provide a robust
We found that uniqhtt demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.