# -*- coding: utf-8 -*- from scrapy import Spider, Request class YiniuYunSpider(Spider): name = '16yun' allowed_domains = ['current-ip.16yun.cn'] start_url = 'http://current-ip.16yun.cn:802/ip' def start_requests(self): yield Request(self.start_url, callback=self.parse_list) def parse_list(self, response): with open('16yun.html', 'w', encoding='utf-8') as f: f.write(response.text)