@rexxhayanasi/nhentai
v1.0.2
Published
A scraper for NHentai with types
Downloads
28
Maintainers
Readme
TypeScript wrapper to scrape doujins and generate PDFs from NHentai and its mirror sites.
📖 Documentation: [coming soon]
🌐 Supported Sites: [https://nhentai.net|https://nhentai.to]
will be updated if there is a change in the domain from nhentai official
⚙️ Installation
yarn add @rexxhayanasi/nhentai
# or
npm install @rexxhayanasi/nhentai⚠️ Note for nhentai.net Users
Due to Cloudflare protection on nhentai.net, follow these steps:
Open nhentai.net in your browser.
Open Developer Tools (DevTools).
Set a custom User-Agent (you'll use this later).
Wait for Cloudflare clearance (do not close DevTools).
Copy the cf_clearance cookie value from the Network tab.
⏳ The cookie expires after 30 minutes of inactivity, so you may need to repeat this process if needed.
🚀 Usage Examples
import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai()
;(async () => {
const { data } = await nhentai.explore()
console.log(data)
})()import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai()
;(async () => {
const { data } = await nhentai.search('loli', { page: 1 })
const doujin = data[0]
const { images } = await doujin.getContents()
console.log(images.pages)
await images.PDF('loli.pdf') // Returns Buffer if no filename
})()import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai({
site: 'nhentai.net',
user_agent: 'Your Custom User-Agent',
cookie_value: 'cf_clearance=your_cookie_here'
})
;(async () => {
const { data } = await nhentai.explore()
console.log(data)
})()or using default Cookies Npm @rexxhayanasi/nhentai (MAY NOT WORK)
import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai({
site: 'nhentai.net',
user_agent: 'Your Custom User-Agent'
})
//no cookie_content if this Npm has prepared manual cookies
;(async () => {
const { data } = await nhentai.explore()
console.log(data)
})()import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai({ site: 'nhentai.to' })
nhentai.validate('172').then(console.log)import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai()
nhentai.getDoujin(172).then(console.log)import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai()
nhentai.getRandom().then(console.log)import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai()
nhentai.getDoujin('2456').then(async (res) => {
await res.images.download('nhentai') // Save to folder
})import { NHentai } from '@rexxhayanasi/nhentai'
const nhentai = new NHentai()
nhentai.getRandom().then(async (res) => {
await res.images.zip('nhentai.zip') // Returns Buffer if no filename
})📬 License & Contributions
Licensed under MIT. Feel free to open issues or contribute via pull requests!
⚠️ This is not an official NHentai API. Use responsibly.
