-
Notifications
You must be signed in to change notification settings - Fork 1
/
porker.py
49 lines (45 loc) · 1.62 KB
/
porker.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
__author__ = 'seyriz'
from urllib.request import *
from urllib.error import *
from urllib.parse import *
from sys import argv
from os import path, mkdir
import time
class porker(object):
def __init__(self):
self.namu = "https://namu.wiki/raw/"
# self.document = argv[1]
self.document = "SCP 재단"
self.document_urlencoded = quote(self.document)
self.headers = {'User-Agent' : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36"}
self.pork()
def pork(self):
if(not path.exists(self.document)):
mkdir(self.document)
url = self.namu + self.document_urlencoded + "?rev="
rev = 1
while(True):
try:
print("rev : ", rev)
if(path.exists(self.document+"/"+str(rev)+".namu")):
pass
else:
req = Request(url=url+str(rev), headers=self.headers)
response = urlopen(req)
html = response.read().decode()
try:
if(html.index("g-recaptcha") > 0):
print("Too many request ERROR")
break
except :
pass
f = open(self.document+"/"+str(rev)+".namu", mode='w')
f.write(html)
f.close()
time.sleep(3)
rev += 1
except HTTPError as e:
print(e)
break
if(__name__ == "__main__"):
porker()