-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnhentai.py
79 lines (70 loc) · 2.42 KB
/
nhentai.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python
import requests
from sys import argv
print("please fill the empty fields")
print("if you face problem with tor, make sure you have your tor running. and in case change the port")
cookies = {
'__cfduid': '',
'csrftoken': '',
'sessionid': '',
'cf_use_ob': '0',
}
user_agent = ""
x_csrftoken = ""
def tor_session():
session = requests.session()
session.proxies = {
'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'
}
return session
print("use tor?\n(type yes or press enter: )", end="")
if input() == "yes":
session = tor_session()
else:
session = requests.session()
if argv[1] == "code":
while True:
code = input("code:").replace("#", "")
if not str.isnumeric(code):
print("that wasn't a code! (exiting)")
exit(1)
headers = {
'User-Agent': user_agent,
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Referer': f'https://nhentai.net/g/{code}/',
'X-Requested-With': 'XMLHttpRequest',
'X-CSRFToken': x_csrftoken,
'Origin': 'https://nhentai.net',
'DNT': '1',
'Connection': 'keep-alive',
'TE': 'Trailers',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
}
response = session.post(f'https://nhentai.net/api/gallery/{code}/favorite', headers=headers, cookies=cookies)
print(code + ':', response.text)
else:
cfile = input("file:")
with open(cfile, 'r') as f:
content = f.readlines()
content = [x.strip() for x in content]
for code in content:
code = code.replace("#", "")
headers = {
'User-Agent': user_agent,
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'Referer': f'https://nhentai.net/g/{code}/',
'X-Requested-With': 'XMLHttpRequest',
'X-CSRFToken': x_csrftoken,
'Origin': 'https://nhentai.net',
'DNT': '1',
'Connection': 'keep-alive',
'TE': 'Trailers',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
}
response = session.post(f'https://nhentai.net/api/gallery/{code}/favorite', headers=headers, cookies=cookies)
print(code + ':', response.text)