
Lv.1
夕阳西下 一缕余晖
在 【知识帝】知识帝再次...........卷土重来,而且还恶意举报!!! 中回复
import requests
import time
import re
url = 411953
times = 0
headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Type': 'application/json;charset=UTF-8',
'Cookie': '',
'Host': 'api.codemao.cn',
'Origin': 'https://shequ.codemao.cn',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'User-Agent': ''
}
html = requests.get(
'https://api.codemao.cn/web/forums/posts/{}/details'.format(4555555), headers=headers).json()
error = html
slep = False
def tryy(url, headers, error):
html = requests.get(url, headers=headers).json()
try:
if html['error_code'] == error['error_code']:
return False
else:
return True
except:
return True
def sleep(url, headers, error):
html = requests.get(
'https://api.codemao.cn/web/forums/posts/{}/details'.format(url), headers=headers).json()
try:
if html['error_code'] == error['error_code']:
return True
else:
return False
except:
return False
def match(text):
last = None
first = re.search('互',text)
if first != None:
first = first.group()
first = '{}.*?'.format(first)
second = re.search('{}赞|{}关|{}收藏|{}再创|{}在创|{}在创作|{}再创作'.format(
first,first,first,first,first,first,first),text)
if second != None:
second = second.group()
last = 1
print(second)
else:
first = re.search('[点赞]',text)
if first != None:
first = first.group()
first = '{}.*?'.format(first)
second = re.search('{}能不能|{}可否|{}看一下|{}给|{}点|{}赞|{}也'.format(
first,first,first,first,first,first,first),text)
if second != None:
second = second.group()
last = 2
print(second)
else:
first = re.search('0-20|一|二|三|四|五|六|七|八|九|十',text)
if first != None:
first = first.group()
second = re.search('{}赞|{}关|{}收藏|{}再创|{}在创|{}在创作|{}再创作'.format(
first,first,first,first,first,first,first),text)
if second != None:
second = second.group()
second = '{}.*?'.format(second)
third = re.search('{}[回换]'.format(second),text)
if third != None:
third = third.group()
third = '{}.*?'.format(third)
fourth = re.search('{}赞|{}关|{}收藏|{}再创|{}在创|{}在创作|{}再创作'.format(
third,third,third,third,third,third,third),text)
if fourth != None:
fourth = fourth.group()
print(fourth)
last = 3
return last
def communityprint(resp,url):
userid = int(resp['user']['id'])
username = resp['user']['nickname']
print('-----------------')
print(userid)
print('-----------------')
print(username)
print('-----------------')
print('https://shequ.codemao.cn/community/' + str(url))
def answer(url,times, headers, error):
while True:
boo = tryy(
'https://api.codemao.cn/web/forums/posts/{}/details'.format(url), headers, error)
if boo == True:
resp = requests.get('https://api.codemao.cn/web/forums/posts/{}/details?offset=1&limit=10'.format(url),headers = headers).json()
text = resp['content'] + resp['title']
answer_ = requests.get(
'https://api.codemao.cn/web/forums/posts/{}/replies?page=1&limit=10&sort=-created_at'.format(url),headers = headers).json()
for i in answer_['items']:
true = re.search('不|杜绝|远离|萌新|互赞大佬|互赞的大佬|xxs|xs|小学生|小孩子|小孩纸|pen|屁|pi|毛',i['content'])
if match(i['content']) != None and true == None:
communityprint(i,url)
true = re.search('不|杜绝|远离|萌新|互赞大佬|互赞的大佬|xxs|xs|小学生|小孩子|小孩纸|pen|屁|pi|毛',text)
if true == None:
if match(text) != None:
communityprint(resp,url)
url += 1
times = 0
elif times < 5:
answer(url+1,times+1, headers, error)
if times > 0:
break
else:
return True, url
break
elif times == 5:
break
while 1:
if slep == True:
slep = sleep(url, headers, error)
else:
slep, url = answer(url, times, headers, error)
2021-12-31T19:27:38 点赞:1
在 【知识帝】知识帝再次...........卷土重来,而且还恶意举报!!! 中回复
知识帝对不起,仔细一想其实你也就吹吹牛而已,吹牛在编程猫也不算错谬,所以对不起
2022-01-01T08:46:36 点赞:0