1、http://www.xicidaili.com/wt 国内免费代理网站
2、利用scrapy爬取该网站内的IP地址与端口,写入txt文档
3、编写脚本测试txt文档中的ip地址与端口是否可用
4、将可用ip地址与端口输入txt文档
————————————————————————
1、编写Item类
由于我们只需要ip地址与端口,所以只写一个属性即可
# -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
import scrapy
class IpItem(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
pass
class IpInfoItem(scrapy.Item):
ip=scrapy.Field()
2、编写spider
# -*- coding: utf-8 -*-