parse html file to get proxies :return:
(self, html)
| 14 | urls = [BASE_URL.format(page=page) for page in range(1, MAX_PAGE + 1)] |
| 15 | |
| 16 | def parse(self, html): |
| 17 | """ |
| 18 | parse html file to get proxies |
| 19 | :return: |
| 20 | """ |
| 21 | doc = pq(html) |
| 22 | trs = doc('.containerbox table tr:gt(0)').items() |
| 23 | for tr in trs: |
| 24 | host = tr.find('td:nth-child(1)').text() |
| 25 | port = int(tr.find('td:nth-child(2)').text()) |
| 26 | yield Proxy(host=host, port=port) |
| 27 | |
| 28 | |
| 29 | if __name__ == '__main__': |