# NHentai

<figure><img src="https://1729253516-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh9iC1635f9DsT4f10Toq%2Fuploads%2Fwe3LYGBHjcDt9qxCRSDP%2FMens-Nhentai-logo-shirt.png?alt=media&#x26;token=2220436f-e8a1-4b40-ac77-3419055d67dc" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
**This has become optional since NHentai stopped requiring Cloudflare's cookies**
{% endhint %}

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.

## Retrieving User Agent And CF\_Clearence Cookie

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).&#x20;
* **For Firefox**: Right-click on the webpage and select Inspect Element or press Ctrl + Shift + I (or Cmd + Option + I on Mac).

## Navigate to the Network Tab

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.

<figure><img src="https://1729253516-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fh9iC1635f9DsT4f10Toq%2Fuploads%2F7DlpJVVVmyOZWZvFxRzw%2Fuser-agent.png?alt=media&#x26;token=9e2e28d0-00f0-46c2-979c-e868554e57a7" alt=""><figcaption></figcaption></figure>

## 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:

{% tabs %}
{% tab title="Python" %}

```python
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)

```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
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.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.minorin.io/enma/documentation/authentication/nhentai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
