xididaili crawler, https://www.xicidaili.com/
| 7 | |
| 8 | |
| 9 | class XicidailiCrawler(BaseCrawler): |
| 10 | """ |
| 11 | xididaili crawler, https://www.xicidaili.com/ |
| 12 | """ |
| 13 | urls = [BASE_URL] |
| 14 | ignore = True |
| 15 | |
| 16 | def parse(self, html): |
| 17 | """ |
| 18 | parse html file to get proxies |
| 19 | :return: |
| 20 | """ |
| 21 | doc = pq(html) |
| 22 | items = doc('#ip_list tr:contains(高匿)').items() |
| 23 | for item in items: |
| 24 | country = item.find('td.country').text() |
| 25 | if not country or country.strip() != '高匿': |
| 26 | continue |
| 27 | host = item.find('td:nth-child(2)').text() |
| 28 | port = int(item.find('td:nth-child(3)').text()) |
| 29 | yield Proxy(host=host, port=port) |
| 30 | |
| 31 | |
| 32 | if __name__ == '__main__': |