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
HGladIator
V2EX  ›  Python

scrapy-redis 的 start_urls 添加很多个,怎么做便捷?

  •  
  •   HGladIator · 2017-05-26 10:05:41 +08:00 · 4369 次点击
    这是一个创建于 2528 天前的主题,其中的信息可能已经有所发展或是发生改变。
    scrapy-redis 的 start_urls 需要去 redis 添加,可是当添加多个 url 的时候很麻烦,有没有方便的做法
    11 条回复    2017-05-26 11:46:56 +08:00
    PythoneerDev6
        1
    PythoneerDev6  
       2017-05-26 10:09:49 +08:00
    麻烦之处 在哪
    qsnow6
        2
    qsnow6  
       2017-05-26 10:11:31 +08:00
    start_requests
    knightdf
        3
    knightdf  
       2017-05-26 10:19:35 +08:00
    同问怎么麻烦?虽然没用 scrapy-redis
    HGladIator
        4
    HGladIator  
    OP
       2017-05-26 10:34:29 +08:00
    @PythoneerDev6 #1
    @knightdf #3
    需要很长一串啊 一个一个加进去 比如我有 50 个页码怎么加
    ```
    127.0.0.1:6379> lpush yourspider:start_urls https://www.v2ex.com/t/363913
    ```
    这样的 url 不是要写 50 个?
    HGladIator
        5
    HGladIator  
    OP
       2017-05-26 10:35:10 +08:00
    @qsnow6 #2 这个写在 spider 里面吗
    knightdf
        6
    knightdf  
       2017-05-26 10:50:04 +08:00
    @HGladIator 循环啊,你是手动加的么?直接写个 py 脚本不一下加进去了
    HGladIator
        7
    HGladIator  
    OP
       2017-05-26 11:01:02 +08:00
    @knightdf #6 我才不会手动呢,我想着应该会有更便捷的高级方法
    HGladIator
        8
    HGladIator  
    OP
       2017-05-26 11:07:47 +08:00
    我还是老老实实写脚本吧
    sunchen
        9
    sunchen  
       2017-05-26 11:19:26 +08:00
    start_requests 读文件
    shimmerh
        10
    shimmerh  
       2017-05-26 11:44:55 +08:00
    大哥,你写个 python 脚本来导入这么难吗?
    HGladIator
        11
    HGladIator  
    OP
       2017-05-26 11:46:56 +08:00
    @shimmerh #10 看这便捷的方法不是找到了吗, start_requests 读文件啊
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2492 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 15:46 · PVG 23:46 · LAX 08:46 · JFK 11:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.