nhentai-ts
Scrap and build a PDF of a doujin from NHentai. Check the available sites here.
Documentation
Installation
yarn add @shineiichijo/nhentai-ts
Note
If you're choosing nhentai.net
for the site, make sure to follow the following steps (as the site has enabled cloudflare protection):
- Open https://nhentai.net/ in your browser.
- Open Dev Tools and set the User Agent to what you want (you'll need the user agent).
- Reload the site and wait for the clearance of cloudflare (without closing the Dev Tools).
- Save the cookie value from the Network Tab (
cf_clearance
value).
After following all these steps, you are all set. You can also check the example of it (at the first one). Remember, the cookie value expires after 30 minutes of inactivity. So, you might have to do the above steps again (in case you're gonna use it again).
Usage Examples
import { NHentai } from '@shineiichijo/nhentai-ts'
const user_agent = 'User Agent'
const cookie_value = 'cf_clearance=abcdefghijklmnopq'
const nhentai = new NHentai({ site: 'nhentai.net', user_agent, cookie_value })
;(async () => {
const { data } = await nhentai.explore()
console.log(data)
})()
import { NHentai } from '@shineiichijo/nhentai-ts'
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' )
})()
import { NHentai } from '@shineiichijo/nhentai-ts'
const nhentai = new NHentai({ site: 'nhentai.to' })
nhentai.validate('172').then(console.log)
import { NHentai } from '@shineiichijo/nhentai-ts'
const nhentai = new NHentai()
nhentai.explore(2 ).then(console.log)
import { NHentai } from '@shineiichijo/nhentai-ts'
const nhentai = new NHentai()
nhentai.getRandom().then(console.log)
import { NHentai } from '@shineiichijo/nhentai-ts'
const nhentai = new NHentai()
nhentai.getDoujin(172).then(console.log)
import { NHentai } from '@shineiichijo/nhentai-ts'
const nhentai = new NHentai()
nhentai.getDoujin('2456').then(
async (res) =>
await res.images.download(
'nhentai'
)
)
import { NHentai } from '@shineiichijo/nhentai-ts'
const nhentai = new NHentai()
nhentai.getRandom().then(
async (res) =>
await res.images.zip(
'nhentai.zip'
)
)