MCPcopy
hub / github.com/PyQt5/PyQt / _parseHtml

Method _parseHtml

QGridLayout/HotPlaylist.py:89–112  ·  view source on GitHub ↗
(self, html)

Source from the content-addressed store, hash-verified

87 return (src[i:i + length] for i in range(len(src)) if i % length == 0)
88
89 def _parseHtml(self, html):
90 # print(html)
91 # encoding = chardet.detect(html) or {}
92 # html = html.decode(encoding.get("encoding","utf-8"))
93 html = HTML(html)
94 # 查找所有的li list_item
95 lis = html.xpath("//ul[@id='m-pl-container']/li")
96 # print(lis)
97 if not lis:
98 self.Page = -1 # 后面没有页面了
99 return
100 lack_count = self._layout.count() % 35 # 获取布局中上次还缺几个5行*6列的标准
101 row_count = int(self._layout.count() / 5) # 行数
102 print("lack_count:", lack_count)
103 self.Page += 1 # 自增+1
104 if lack_count != 0: # 上一次没有满足一行5个,需要补齐
105 lack_li = lis[:lack_count]
106 lis = lis[lack_count:]
107 self._makeItem(lack_li, row_count) # 补齐
108 if lack_li and lis:
109 row_count += 1
110 self._makeItem(lis, row_count) # 完成剩下的
111 else:
112 self._makeItem(lis, row_count)
113
114 def _makeItem(self, li_s, row_count):
115 li_s = self.splist(li_s, 5)

Callers 1

onFinishedMethod · 0.95

Calls 2

_makeItemMethod · 0.95
countMethod · 0.45

Tested by

no test coverage detected