|
发表于 2020-9-2 00:34:41
|
显示全部楼层
笨笨地试用了一下正则表达,应该还好:- l7 P9 ]7 |# E+ _
@export('The_Little_Dict')1 O. V; d6 S' J R+ r7 @. w/ e
def The_Little_Dict(self):
: u; s# A( f3 f) H* ^3 l8 T4 `5 o, S def_distribution = '': f, Y0 \: @8 B" ` S! I3 Y
m = re.findall(r'(<link.*?<hr/></div>)|(</div><div\s+class="word-frequency">.*?<div\s+class="coca">)|(<span\s+class="pos">.*?<div\s+class="total">\d+</div>)|(</div><div\s+class="coca2">.*?</span></div></div>)', self.get_html_all())
& A5 D# A* r2 U; p if m:
/ r9 Z, y* l& K$ E3 M& H6 H3 s for i in range(len(m)):
# P Y0 o! R& l% U$ C9 g for j in range(len(m)):( `1 i5 a V* [; O. l; Q
if not (m[j] == ''):
, M' w# x" r( U def_distribution += m[j]
. Q8 l9 i1 \2 Y7 ]: Y! [* B. P, Y return def_distribution# H" {( C3 \ `. o# D
return ''
$ Y5 f: F% n! W5 w3 F* U$ {
( O$ Y% p+ c$ f1 V9 _; l0 |, L( h% a$ n+ q
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?免费注册
x
|