(self, html)
| 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) |
no test coverage detected