V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Fizzyi
V2EX  ›  Python

scrapy 代理 ip 失效后更换 IP

  •  
  •   Fizzyi · 2019-05-27 17:15:11 +08:00 · 2600 次点击
    这是一个创建于 1767 天前的主题,其中的信息可能已经有所发展或是发生改变。
    求助各位 v 友,我使用 scrapy 框架爬取数据使用了代理 ip,想问下如何在当前 ip 失效或者被封了之后自动更换 ip 呢
    3 条回复    2019-06-05 15:58:33 +08:00
    tikazyq
        1
    tikazyq  
       2019-05-27 17:29:56 +08:00
    需要记录代理 ip 的有效性,如果是使用了 API,先缓存到数据库中。

    顺便打个广告,Crawlab 是一个专注于爬虫的集成了爬虫管理、任务调度、任务监控、数据分析等模块的分布式爬虫管理平台,非常适合对爬虫管理、爬虫工程化有要求的开发者及企业

    https: //github.com/tikazyq/crawlab
    lucays
        2
    lucays  
       2019-05-28 19:51:53 +08:00 via Android
    有中间件的,在 middleware 里写,至少按照 response.status 判断是不是 200
    popbayun
        3
    popbayun  
       2019-06-05 15:58:33 +08:00
    建个代理 IP 池,失效或被 ban 就从池子里剔除掉
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1018 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:44 · PVG 03:44 · LAX 12:44 · JFK 15:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.