89ip crawler, http://api.89ip.cn
| 7 | |
| 8 | |
| 9 | class Ip89Crawler(BaseCrawler): |
| 10 | """ |
| 11 | 89ip crawler, http://api.89ip.cn |
| 12 | """ |
| 13 | urls = [BASE_URL] |
| 14 | |
| 15 | def parse(self, html): |
| 16 | """ |
| 17 | parse html file to get proxies |
| 18 | :return: |
| 19 | """ |
| 20 | ip_address = re.compile('([\d:\.]*)<br>') |
| 21 | hosts_ports = ip_address.findall(html) |
| 22 | for addr in hosts_ports: |
| 23 | addr_split = addr.split(':') |
| 24 | if(len(addr_split) == 2): |
| 25 | host = addr_split[0] |
| 26 | port = addr_split[1] |
| 27 | yield Proxy(host=host, port=port) |
| 28 | |
| 29 | |
| 30 | if __name__ == '__main__': |