文明观犇器
大家来文明观犇吧!
优点:
-
可以忍住不水
-
可以相对心平气和不对线
-
可以防止奇怪图片
缺点:
-
不能Md
-
不能图片
-
比较单调
-
八秒一次比较奇怪
代码:
import urllib.request
import time
tag='<span class=\"am-badge am-radius lg-bg-purple\">'
s={'2333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333'}
while True:
fal=0
stk=0
tot=[]
tmptmp=[]
for h in urllib.request.urlopen(r'https://www.luogu.com.cn/feed/all?page=1').read().decode('utf-8').split('\n'):
#print(h)
if h!=' .feed-comment p {' and h!=' margin-bottom: 0;' and h!=' }':
if h.find('发表了新帖子')!=-1:
fal=1
if h.find('<li')!=-1:
stk+=1
if h.find('</li>')!=-1:
stk-=1
if not stk:
if fal==0:
tot.append(''.join(tmptmp))
else:
fal=0
tmptmp=[]
continue
if fal==1:
continue
#print(h)
h=h.replace('‮','').replace(' ','').replace(tag,'<')
#print(h)
a=list(h)
tmpstr=''
flg,tmp=0,1
for c in a:
if c=='<':
tmp=0
if tmp:
tmpstr+=c
flg=1
if c=='>':
tmp=1
if flg:
tmptmp.append('\t'+tmpstr+'\n')
for t in reversed(tot):
t=t.replace('<','<').replace('>','>').replace('"','\"')
if t in s:
continue
s.add(t)
print('@',end='')
for c in range(1,len(t)):
print(t[c],end='')
print('')
time.sleep(8)
制作不易,转载请注明出处,谢谢!
bug修复:Tag的处理