NHentai

Authentication Flow for NHentai Source in Enma When using Enma to access content from NHentai, it's crucial to understand that NHentai employs Cloudflare's anti-bot measures, which necessitate a special authentication flow to ensure seamless access. This process involves retrieving a User-Agent and a CF_Clearance cookie, which are essential for bypassing Cloudflare's security checks and accessing NHentai's content through the Enma library.

Open your web browser and navigate to the NHentai website. This step is necessary to trigger and pass Cloudflare's anti-bot verification manually.

Open Developer Tools

  • For Google Chrome: Right-click on the webpage and select Inspect or simply press Ctrl + Shift + I (or Cmd + Option + I on Mac).

  • For Firefox: Right-click on the webpage and select Inspect Element or press Ctrl + Shift + I (or Cmd + Option + I on Mac).

In the Developer Tools panel, click on the Network tab. This tab captures all network requests made by the webpage.

Reload the Page

With the Network tab open, reload the NHentai website by pressing Ctrl + R (or Cmd + R on Mac). This ensures that all network requests are captured.

Select nhentai.net Request

After reloading, you'll see a list of files on the left side of the Network tab. Click on the first file named nhentai.net. This represents the main request to the NHentai website.

Find the Request Headers

On the right side, you'll see several tabs like Headers, Preview, Response, etc. Make sure you're on the Headers tab. Scroll down until you find a section named Request Headers.

Copy User-Agent and CF_Clearence Tokens

  • user-agent: This is a string that tells the server which web browser is being used. Look for an entry named User-Agent and copy its value.

  • cf_clearance: This is a specific cookie set by CloudFlare for security purposes. Look for an entry named cf_clearance and copy its value.

Setting Enma Up With New Tokens

Once you have obtained the CF_Clearance cookie and your User-Agent, you need to configure Enma to use these values when making requests to NHentai. This involves setting the CF_Clearance cookie and the User-Agent in your script or application where you're utilizing Enma to access NHentai.

Here's a general way to set these in Enma:

from enma import Enma

config = CloudFlareConfig(
    user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36',
    cf_clearance=''
)

enma = Enma()
enma.source_manager.set_source('nhentai')
enma.source_manager.source.set_config(config=config)

The user-agent and cf_clearance values can change over time. If you encounter issues accessing NHentai through the Enma library, you might need to repeat the above steps to get updated values.

Last updated