为了账号安全,请及时绑定邮箱和手机立即绑定

我自定义了中间件specified_proxy,在控制台能看到启动,断点进不来

https://img1.sycdn.imooc.com//5bfba25a0001923319201048.jpg

https://img1.sycdn.imooc.com//5bfba25b0001a02419201048.jpg

middlewares.py
class specified_proxy(object):
    def proccess_request(self,request,spider):
        #随机选取代理Ip
        PROXIES = ['http://183.207.95.27:80', 'http://111.6.100.99:80', 'http://122.72.99.103:80',
                   'http://106.46.132.2:80', 'http://112.16.4.99:81', 'http://123.58.166.113:9000',
                   'http://118.178.124.33:3128', 'http://116.62.11.138:3128', 'http://121.42.176.133:3128',
                   'http://111.13.2.131:80', 'http://111.13.7.117:80', 'http://121.248.112.20:3128',
                   'http://112.5.56.108:3128', 'http://42.51.26.79:3128', 'http://183.232.65.201:3128',
                   'http://118.190.14.150:3128', 'http://123.57.221.41:3128', 'http://183.232.65.203:3128',
                   'http://166.111.77.32:3128', 'http://42.202.130.246:3128', 'http://122.228.25.97:8101',
                   'http://61.136.163.245:3128', 'http://121.40.23.227:3128', 'http://123.96.6.216:808',
                   'http://59.61.72.202:8080', 'http://114.141.166.242:80', 'http://61.136.163.246:3128',
                   'http://60.31.239.166:3128', 'http://114.55.31.115:3128', 'http://202.85.213.220:3128']
        random_proxy = random.sample(PROXIES, 1)
        request.meta['proxy'] = random_proxy

settings.py
DOWNLOADER_MIDDLEWARES = {
   #'ScrapyTest.middlewares.ScrapytestDownloaderMiddleware': 543,
    'ScrapyTest.middlewares.specified_proxy': 543,
    'ScrapyTest.middlewares.specified_useragent': 544
}


正在回答

举报

0/150
提交
取消

我自定义了中间件specified_proxy,在控制台能看到启动,断点进不来

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信