편집 필터 기록

편집 필터 둘러보기 (처음 | 최근 필터의 바뀜 | 과거의 편집 검토하기 | 편집 필터 기록)
기록 49,296에 대한 자세한 정보

2022년 9월 28일 (수) 21:53: 하늘 (토론 | 기여)님이 사용자:하늘/소스/명조체 다운에서 "edit" 동작을 수행하여 필터 0이(가) 작동했습니다. 조치: 태그; 필터 설명: (검사)

편집에서 바뀐 내용

<syntaxhighlight lang="python">
{{삭제|}}
import requests
import datetime
import os
import sys
import re
import time
 
S = requests.Session()
URL = "https://librewiki.net/api.php"
 
class bot:
def __init__(self):
self.S = requests.Session()
self.csrftoken = ''
self.url = "https://librewiki.net/api.php"
 
def get_csrftoken(self):
PARAMS = {"action": "query", "meta": "tokens", "format": "json"}
DATA = self.S.get(url=self.url, params=PARAMS).json()
self.csrftoken = DATA['query']['tokens']['csrftoken']
 
def login(self, name, password):
# Step 1: Retrieve login token first
PARAMS = {
'action': "query",
'meta': "tokens",
'type': "login",
'format': "json"
}
DATA = self.S.get(url=self.url, params=PARAMS).json()
LOGIN_TOKEN = DATA['query']['tokens']['logintoken']
# Step 2: Send a POST request to login. Using the main account for login is not
# supported. Obtain credentials via Special:BotPasswords
# 봇 비밀번호 설정 권장, 형식 : Caeruleum@asdfqwerzxcvpoiulkjhmnbv
PARAMS = {
"action": "login",
"format": "json",
"lgname": name,
"lgpassword": password,
"lgtoken": LOGIN_TOKEN,
"utf8": 1
}
DATA = self.S.post(self.url, data=PARAMS).json()
if DATA["login"]["result"] == "Success":
print("로그인 성공")
self.get_csrftoken()
else:
print("로그인 실패")
exit()
 
def logout(self):
DATA = self.S.post(self.url, data={"action": "logout",
"token": self.csrftoken, "format": "json"}).json()
print("로그아웃")
print(DATA)
 
 
def download(url, file_name):
with open(file_name, "wb") as file:
response = requests.get(url)
file.write(response.content)
# OS = platform.system()
 
 
def GW_download(folder, hanja, lang, fontType):
if lang == 'j':
fontType = fontType + '-일본'
elif lang == 'g':
fontType = fontType + '-중국'
elif lang == 't':
fontType = fontType + '-대만'
elif lang == 'h':
fontType = fontType + '-홍콩'
elif lang == 'v':
fontType = fontType + '-베트남'
charcode = hex(ord(hanja)).replace('0x', 'u') +'-'+lang
filename = hanja + '-' + fontType + '.svg'
GW_query_URL = "https://glyphwiki.org/json?name="+charcode
GW_download_URL = "https://glyphwiki.org/glyph/"+charcode + '.svg'
R = bot.S.get(GW_query_URL).json()
if R['version'] != None:
print(charcode)
download(GW_download_URL, folder + '/' + filename)
else:
print(charcode + ' 없음')
 
 
 
def api_upload(source, filename, category, licence):  # 파일 소스, 파일 이름, 분류, 라이선스
#수동으로 파일을 확인해야 하기 때문에 api 업로드하지 않음
uploadPARAMS = {
"action": "upload",
"filename": filename,
"format": "json",
# PD-author # 한자/문자/명조
"text": "== 파일의 설명 ==\n{{파일 정보\n|설명 = \n|출처 = 글리프위키\n|날짜 = \n|만든이 = \n|기타 = \n}}\n[[분류:"+category+"]]\n== 라이선스 ==\n{{"+licence+"}}",
"async": 1,
"token": bot.csrftoken,
"ignorewarnings": 1
}
FILE = {'file': (filename, open(source, 'rb'), 'multipart/form-data')}
DATA = S.post(URL, files=FILE, data=uploadPARAMS).json()
print(DATA)
 
def GW_upload(folder, hanja, fontType):
filename = hanja + '-' + fontType + '.svg'
GW_download(folder, hanja, fontType)
time.sleep(10)
api_upload(folder + '/' + filename, filename,
  '한자/문자/'+fontType, 'PD-author')
 
bot = bot()
#bot.login("Caeruleum", "Caeruleum@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
 
currentDate = str(datetime.datetime.now())
currentDate = currentDate.split('.')[0]
 
temp = open('date.txt', 'r')
preDate = temp.readline().replace('-', ':')
temp.close()
print(preDate)
date_file = open('date.txt', 'w')
date_file.write(currentDate)
date_file.close()
 
if not(os.path.isdir(currentDate)):
os.makedirs(os.path.join(currentDate))
 
PARAMS = {
"action": "query",
"format": "json",
"list": "categorymembers",
"utf8": 1,
"cmnamespace": "1600",
"cmtitle": "분류:한자/문자",
"cmprop": "title|timestamp",
"cmtype": "page",
"cmlimit": "max",
"cmsort": "timestamp",
#"cmstart": preDate
}
DATA = S.get(url=URL, params=PARAMS).json()
PAGES = DATA['query']['categorymembers']
 
hanjaList = open(currentDate + '/list.csv', 'a')
for page in PAGES:
hanja = page['title'].split('/')[1] + '\n'
hanjaList.write(hanja)
hanjaList.close()
hanjaList = open(currentDate + '/list.csv', 'r')
 
while True:
hanja = hanjaList.readline().replace('\n', '')
if not hanja:
break
PARAMS = {
"action": "query",
"format": "json",
"prop": "revisions",
"formatversion": "2",
"rvprop": "content",
"rvslots": "*",
"titles": '시리즈:리브레 한자사전/' + hanja
}
DATA = S.get(url=URL, params=PARAMS).json()
PAGE = DATA['query']['pages'][0]['revisions'][0]['slots']['main']['content']
hanja = re.search('한자 =(.+?)\n', PAGE).group(1).strip()
print('------------------')
print(hanja)
japanHanja = re.search('신자체 =(.+?)\n', PAGE)
chineseHanja = re.search('간체자 =(.+?)\n', PAGE)
fontType = '명조'
GW_download(currentDate, hanja, 'k', fontType)
GW_download(currentDate, hanja, 't', fontType)
GW_download(currentDate, hanja, 'h', fontType)
GW_download(currentDate, hanja, 'v', fontType)
if japanHanja == None:
japanHanja = hanja
else:
japanHanja = japanHanja.group(1).strip()
if japanHanja == "":
japanHanja = hanja
if chineseHanja == None:
chineseHanja = hanja
else:
chineseHanja = chineseHanja.group(1).strip()
if chineseHanja == "":
chineseHanja = hanja
GW_download(currentDate, japanHanja, 'j', fontType)
GW_download(currentDate, chineseHanja, 'g', fontType)
 
#bot.logout()
 
</syntaxhighlight>

명령 변수

변수
사용자의 편집 수 (user_editcount)
34432
사용자 계정 이름 (user_name)
'하늘'
사용자 계정 만든 후 지난 시간 (user_age)
85018178
사용자 권한 그룹 (자동으로 부여된 권한 포함) (user_groups)
[ 0 => '*', 1 => 'user', 2 => 'autoconfirmed' ]
문서 ID (page_id)
181194
문서 이름공간 (page_namespace)
2
(이름공간을 뺀) 문서 제목 (page_title)
'하늘/소스/명조체 다운'
전체 문서 제목 (page_prefixedtitle)
'사용자:하늘/소스/명조체 다운'
동작 (action)
'edit'
편집 요약/이유 (summary)
''
이전 콘텐츠 모델 (old_content_model)
'wikitext'
새 콘텐츠 모델 (new_content_model)
'wikitext'
편집 전 과거 문서의 위키텍스트 (old_wikitext)
'<syntaxhighlight lang="python"> import requests import datetime import os import sys import re import time S = requests.Session() URL = "https://librewiki.net/api.php" class bot: def __init__(self): self.S = requests.Session() self.csrftoken = '' self.url = "https://librewiki.net/api.php" def get_csrftoken(self): PARAMS = {"action": "query", "meta": "tokens", "format": "json"} DATA = self.S.get(url=self.url, params=PARAMS).json() self.csrftoken = DATA['query']['tokens']['csrftoken'] def login(self, name, password): # Step 1: Retrieve login token first PARAMS = { 'action': "query", 'meta': "tokens", 'type': "login", 'format': "json" } DATA = self.S.get(url=self.url, params=PARAMS).json() LOGIN_TOKEN = DATA['query']['tokens']['logintoken'] # Step 2: Send a POST request to login. Using the main account for login is not # supported. Obtain credentials via Special:BotPasswords # 봇 비밀번호 설정 권장, 형식 : Caeruleum@asdfqwerzxcvpoiulkjhmnbv PARAMS = { "action": "login", "format": "json", "lgname": name, "lgpassword": password, "lgtoken": LOGIN_TOKEN, "utf8": 1 } DATA = self.S.post(self.url, data=PARAMS).json() if DATA["login"]["result"] == "Success": print("로그인 성공") self.get_csrftoken() else: print("로그인 실패") exit() def logout(self): DATA = self.S.post(self.url, data={"action": "logout", "token": self.csrftoken, "format": "json"}).json() print("로그아웃") print(DATA) def download(url, file_name): with open(file_name, "wb") as file: response = requests.get(url) file.write(response.content) # OS = platform.system() def GW_download(folder, hanja, lang, fontType): if lang == 'j': fontType = fontType + '-일본' elif lang == 'g': fontType = fontType + '-중국' elif lang == 't': fontType = fontType + '-대만' elif lang == 'h': fontType = fontType + '-홍콩' elif lang == 'v': fontType = fontType + '-베트남' charcode = hex(ord(hanja)).replace('0x', 'u') +'-'+lang filename = hanja + '-' + fontType + '.svg' GW_query_URL = "https://glyphwiki.org/json?name="+charcode GW_download_URL = "https://glyphwiki.org/glyph/"+charcode + '.svg' R = bot.S.get(GW_query_URL).json() if R['version'] != None: print(charcode) download(GW_download_URL, folder + '/' + filename) else: print(charcode + ' 없음') def api_upload(source, filename, category, licence): # 파일 소스, 파일 이름, 분류, 라이선스 #수동으로 파일을 확인해야 하기 때문에 api 업로드하지 않음 uploadPARAMS = { "action": "upload", "filename": filename, "format": "json", # PD-author # 한자/문자/명조 "text": "== 파일의 설명 ==\n{{파일 정보\n|설명 = \n|출처 = 글리프위키\n|날짜 = \n|만든이 = \n|기타 = \n}}\n[[분류:"+category+"]]\n== 라이선스 ==\n{{"+licence+"}}", "async": 1, "token": bot.csrftoken, "ignorewarnings": 1 } FILE = {'file': (filename, open(source, 'rb'), 'multipart/form-data')} DATA = S.post(URL, files=FILE, data=uploadPARAMS).json() print(DATA) def GW_upload(folder, hanja, fontType): filename = hanja + '-' + fontType + '.svg' GW_download(folder, hanja, fontType) time.sleep(10) api_upload(folder + '/' + filename, filename, '한자/문자/'+fontType, 'PD-author') bot = bot() #bot.login("Caeruleum", "Caeruleum@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") currentDate = str(datetime.datetime.now()) currentDate = currentDate.split('.')[0] temp = open('date.txt', 'r') preDate = temp.readline().replace('-', ':') temp.close() print(preDate) date_file = open('date.txt', 'w') date_file.write(currentDate) date_file.close() if not(os.path.isdir(currentDate)): os.makedirs(os.path.join(currentDate)) PARAMS = { "action": "query", "format": "json", "list": "categorymembers", "utf8": 1, "cmnamespace": "1600", "cmtitle": "분류:한자/문자", "cmprop": "title|timestamp", "cmtype": "page", "cmlimit": "max", "cmsort": "timestamp", #"cmstart": preDate } DATA = S.get(url=URL, params=PARAMS).json() PAGES = DATA['query']['categorymembers'] hanjaList = open(currentDate + '/list.csv', 'a') for page in PAGES: hanja = page['title'].split('/')[1] + '\n' hanjaList.write(hanja) hanjaList.close() hanjaList = open(currentDate + '/list.csv', 'r') while True: hanja = hanjaList.readline().replace('\n', '') if not hanja: break PARAMS = { "action": "query", "format": "json", "prop": "revisions", "formatversion": "2", "rvprop": "content", "rvslots": "*", "titles": '시리즈:리브레 한자사전/' + hanja } DATA = S.get(url=URL, params=PARAMS).json() PAGE = DATA['query']['pages'][0]['revisions'][0]['slots']['main']['content'] hanja = re.search('한자 =(.+?)\n', PAGE).group(1).strip() print('------------------') print(hanja) japanHanja = re.search('신자체 =(.+?)\n', PAGE) chineseHanja = re.search('간체자 =(.+?)\n', PAGE) fontType = '명조' GW_download(currentDate, hanja, 'k', fontType) GW_download(currentDate, hanja, 't', fontType) GW_download(currentDate, hanja, 'h', fontType) GW_download(currentDate, hanja, 'v', fontType) if japanHanja == None: japanHanja = hanja else: japanHanja = japanHanja.group(1).strip() if japanHanja == "": japanHanja = hanja if chineseHanja == None: chineseHanja = hanja else: chineseHanja = chineseHanja.group(1).strip() if chineseHanja == "": chineseHanja = hanja GW_download(currentDate, japanHanja, 'j', fontType) GW_download(currentDate, chineseHanja, 'g', fontType) #bot.logout() </syntaxhighlight>'
편집 후 새 문서의 위키텍스트 (new_wikitext)
'{{삭제|}}'
편집 전후의 차이 (edit_diff)
'@@ -1,195 +1,1 @@ -<syntaxhighlight lang="python"> -import requests -import datetime -import os -import sys -import re -import time - -S = requests.Session() -URL = "https://librewiki.net/api.php" - -class bot: - def __init__(self): - self.S = requests.Session() - self.csrftoken = '' - self.url = "https://librewiki.net/api.php" - - def get_csrftoken(self): - PARAMS = {"action": "query", "meta": "tokens", "format": "json"} - DATA = self.S.get(url=self.url, params=PARAMS).json() - self.csrftoken = DATA['query']['tokens']['csrftoken'] - - def login(self, name, password): - # Step 1: Retrieve login token first - PARAMS = { - 'action': "query", - 'meta': "tokens", - 'type': "login", - 'format': "json" - } - DATA = self.S.get(url=self.url, params=PARAMS).json() - LOGIN_TOKEN = DATA['query']['tokens']['logintoken'] - # Step 2: Send a POST request to login. Using the main account for login is not - # supported. Obtain credentials via Special:BotPasswords - # 봇 비밀번호 설정 권장, 형식 : Caeruleum@asdfqwerzxcvpoiulkjhmnbv - PARAMS = { - "action": "login", - "format": "json", - "lgname": name, - "lgpassword": password, - "lgtoken": LOGIN_TOKEN, - "utf8": 1 - } - DATA = self.S.post(self.url, data=PARAMS).json() - if DATA["login"]["result"] == "Success": - print("로그인 성공") - self.get_csrftoken() - else: - print("로그인 실패") - exit() - - def logout(self): - DATA = self.S.post(self.url, data={"action": "logout", - "token": self.csrftoken, "format": "json"}).json() - print("로그아웃") - print(DATA) - - -def download(url, file_name): - with open(file_name, "wb") as file: - response = requests.get(url) - file.write(response.content) -# OS = platform.system() - - -def GW_download(folder, hanja, lang, fontType): - if lang == 'j': - fontType = fontType + '-일본' - elif lang == 'g': - fontType = fontType + '-중국' - elif lang == 't': - fontType = fontType + '-대만' - elif lang == 'h': - fontType = fontType + '-홍콩' - elif lang == 'v': - fontType = fontType + '-베트남' - charcode = hex(ord(hanja)).replace('0x', 'u') +'-'+lang - filename = hanja + '-' + fontType + '.svg' - GW_query_URL = "https://glyphwiki.org/json?name="+charcode - GW_download_URL = "https://glyphwiki.org/glyph/"+charcode + '.svg' - R = bot.S.get(GW_query_URL).json() - if R['version'] != None: - print(charcode) - download(GW_download_URL, folder + '/' + filename) - else: - print(charcode + ' 없음') - - - -def api_upload(source, filename, category, licence): # 파일 소스, 파일 이름, 분류, 라이선스 - #수동으로 파일을 확인해야 하기 때문에 api 업로드하지 않음 - uploadPARAMS = { - "action": "upload", - "filename": filename, - "format": "json", - # PD-author # 한자/문자/명조 - "text": "== 파일의 설명 ==\n{{파일 정보\n|설명 = \n|출처 = 글리프위키\n|날짜 = \n|만든이 = \n|기타 = \n}}\n[[분류:"+category+"]]\n== 라이선스 ==\n{{"+licence+"}}", - "async": 1, - "token": bot.csrftoken, - "ignorewarnings": 1 - } - FILE = {'file': (filename, open(source, 'rb'), 'multipart/form-data')} - DATA = S.post(URL, files=FILE, data=uploadPARAMS).json() - print(DATA) - -def GW_upload(folder, hanja, fontType): - filename = hanja + '-' + fontType + '.svg' - GW_download(folder, hanja, fontType) - time.sleep(10) - api_upload(folder + '/' + filename, filename, - '한자/문자/'+fontType, 'PD-author') - -bot = bot() -#bot.login("Caeruleum", "Caeruleum@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") - -currentDate = str(datetime.datetime.now()) -currentDate = currentDate.split('.')[0] - -temp = open('date.txt', 'r') -preDate = temp.readline().replace('-', ':') -temp.close() -print(preDate) -date_file = open('date.txt', 'w') -date_file.write(currentDate) -date_file.close() - -if not(os.path.isdir(currentDate)): - os.makedirs(os.path.join(currentDate)) - -PARAMS = { - "action": "query", - "format": "json", - "list": "categorymembers", - "utf8": 1, - "cmnamespace": "1600", - "cmtitle": "분류:한자/문자", - "cmprop": "title|timestamp", - "cmtype": "page", - "cmlimit": "max", - "cmsort": "timestamp", - #"cmstart": preDate -} -DATA = S.get(url=URL, params=PARAMS).json() -PAGES = DATA['query']['categorymembers'] - -hanjaList = open(currentDate + '/list.csv', 'a') -for page in PAGES: - hanja = page['title'].split('/')[1] + '\n' - hanjaList.write(hanja) -hanjaList.close() -hanjaList = open(currentDate + '/list.csv', 'r') - -while True: - hanja = hanjaList.readline().replace('\n', '') - if not hanja: - break - PARAMS = { - "action": "query", - "format": "json", - "prop": "revisions", - "formatversion": "2", - "rvprop": "content", - "rvslots": "*", - "titles": '시리즈:리브레 한자사전/' + hanja - } - DATA = S.get(url=URL, params=PARAMS).json() - PAGE = DATA['query']['pages'][0]['revisions'][0]['slots']['main']['content'] - hanja = re.search('한자 =(.+?)\n', PAGE).group(1).strip() - print('------------------') - print(hanja) - japanHanja = re.search('신자체 =(.+?)\n', PAGE) - chineseHanja = re.search('간체자 =(.+?)\n', PAGE) - fontType = '명조' - GW_download(currentDate, hanja, 'k', fontType) - GW_download(currentDate, hanja, 't', fontType) - GW_download(currentDate, hanja, 'h', fontType) - GW_download(currentDate, hanja, 'v', fontType) - if japanHanja == None: - japanHanja = hanja - else: - japanHanja = japanHanja.group(1).strip() - if japanHanja == "": - japanHanja = hanja - if chineseHanja == None: - chineseHanja = hanja - else: - chineseHanja = chineseHanja.group(1).strip() - if chineseHanja == "": - chineseHanja = hanja - GW_download(currentDate, japanHanja, 'j', fontType) - GW_download(currentDate, chineseHanja, 'g', fontType) - -#bot.logout() - -</syntaxhighlight> +{{삭제|}} '
편집 중 추가된 줄 (added_lines)
[ 0 => '{{삭제|}}' ]
편집이 토르 끝 노드를 통해 바뀌었는 지의 여부 (tor_exit_node)
false
바뀐 시점의 유닉스 시간 기록 (timestamp)
1664369638