用户:
淘气的飞电鼠TQL2查看:0 回复:0 评论:0 创建时间:2022-05-08T12:58:05
【作品展示】

【作品介绍】
大作,需要安requests,bs4,easygui。放在模块的文件夹就可以用了。
【作品源代码】
#coding=utf-8
import requests
import bs4
import re
import easygui
import webbrowser
class NotLondSearchError(Exception):
def __init__(self,message):
super().__init__(message)
def clean(desstr, restr=''):
#过滤表情
try:
co = re.compile(
u'['u'\U0001F300-\U0001F喵F' u'\U0001F680-\U0001F6FF'u'\u2600-\u2B55]+')
except re.error:
co = re.compile(
u'('u'\ud83c[\udf00-\udfff]|'u'\ud83d[\udc00-\ude4f\ude80-\udeff]|'u'[\u2600-\u2B55])+')
return co.sub(restr, desstr)
cc = []
m = []
xxxx =[]
mc =[]
xcvb = []
c = ''
see =[]
fg =0
def searchtime():
global c
if c == '':
raise NotLondSearchError('You not lond mc_search.')
return c
def mcread():
global see
if see == []:
raise NotLondSearchError('You not lond mc_search.')
return see
def mclist():
if mc == []:
raise NotLondSearchError('You not lond mc_search.')
return mc
def mcsearch_lond(s,page=1,mold=0):
global cc
global mc
global xcvb
global c
s = str(s)
response = requests.get('https://search.mcmod.cn/s?key='+s+'&site=&filter=0&mold='+str(mold)+'page='+str(page))
a = bs4.BeautifulSoup(response.text, "html.parser")
targets = a.find_all("p", class_="warning")
if list(targets) == []:
targets = a.find_all("p", class_="info")
n = ''
for i in targets:
for c in i:
if not str(c) == '':
m = str(c)
x = 0
for i in m:
if i == ',':
break
else:
x += 1
v =''
for i in m[x:]:
if i == '。':
break
if i in '0123456789':
v = v+i
m1 = a.find_all("div", class_="head")
v1 = list(m1)
for i in v1:
for z in i:
if str(z) == '123'or str(z)[1] == 'd':
continue
if not str(z)[0] == '(':
aa = r'\d\d\d\d\d\d|\d\d\d\d\d|\d\d\d\d|\d\d\d|\d\d|\d'
c = re.search(aa, str(z))
d = c.group()
cc.append(d)
if 'class' in str(z):
xcvb.append('1')
else:
xcvb.append('0')
for xc in z:
cc.append(xc)
else:
xxxx.append(str(z))
for i in cc:
if str(i).upper() == ''+s.upper()+'':
cc[cc.index(i)] = '["'+str(s)+'"]'
for i in range(len(cc)-1):
if i > len(cc)-1:
break
yn = 0
if i % 2 == 0:
while True:
if yn ==1:
break
try:
vvv = int(cc[i])
yn =1
except ValueError:
ax = cc.pop(i-1)
bx = cc.pop(i-1)
cc.insert(i-1, str(ax)+str(bx))
except IndexError:
break
if not len(xxxx) == len(cc)/2:
while True:
if len(xxxx) == len(cc)/2:
break
xxxx.insert(0,'')
for i in range(1,len(cc)-1,2):
mc.append(clean(xxxx[0]+cc[i]))
cc[i] = xxxx[0]+cc[i]
xxxx.pop(0)
if len(cc)%2 ==0:
mc.append(clean(xxxx[0]+cc[len(cc)-1]))
a = bs4.BeautifulSoup(response.text, "html.parser")
targets = a.find_all("div", class_="body")
cvb = []
for i in targets:
del cvb
cvb = []
for v in i:
if str(v)[0:2] == ' len(mc)-1:
break
if not str(see[ic][-3:]) == '...' or not str(see[ic][len(see[ic])-1]) == '。':
ax = see.pop(ic)
bx = see.pop(ic)
see.insert(ic, str(ax)+str(bx))
else:
ic +=1
if not str(see[ic][len(see[ic])-1]) == '。':
ax = see.pop(ic)
bx = see.pop(ic)
see.insert(ic, str(ax)+str(bx))
else:
ic += 1
except:
break
print(see)
easygui.msgbox(see[mc.index(bn)])
'''
if __name__=='__main__':
while True:
sx= easygui.enterbox('搜索', '搜索')
if not sx == None:
break
mcsearch_lond(sx)
print(mclist())
print(mcread());
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn