推荐学习书目
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
JarvenI
V2EX  ›  Python

求助: scrapyd 不能修改 scrapy 的 settings.py 设置

  •  
  •   JarvenI · Apr 2, 2022 · 2490 views
    This topic created in 1516 days ago, the information mentioned may be changed or developed.

    我是用的 scrapyd+python+scrapyd-api+scrapyd-client 形式,每次运行时启动 scrapyd ,部署项目,部分代码如下

        if subprocess.call('scrapyd') != 0:
            logger.error('启动 scrapyd 失败')
    
        if subprocess.call('scrapyd-deploy 项目名 -p 项目名') != 0:
            logger.error('启动 scrapyd-deploy 失败')
        
        setting = {
        'MYSQL_PASSWD': '123',
    	}
    
        while True:
            if scrapyd.list_spiders('项目名'):
                jobs = scrapyd.list_jobs(PROJECT)
                if not (jobs['pending'] or jobs['running']):
                    scrapyd.schedule(PROJECT, 'spider_name', settings=setting)
    

    试了好几种方式,最后下载个 curl 发现,不能通过

    curl http://localhost:6800/schedule.json -d project=项目名 -d spider=爬虫名 -d setting=MYSQL_PASSWD=123

    方式来修改 setting 里的设置。 按照网上搜索的,也尝试了

    curl http://localhost:6800/schedule.json -d project=项目 -d spider=爬虫 -d MYSQL_PASSWD=123

    也不行

    Supplement 1  ·  Apr 2, 2022
    找到解决办法了,用环境变量来替代 setting.py 里的变量了
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1279 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 17:26 · PVG 01:26 · LAX 10:26 · JFK 13:26
    ♥ Do have faith in what you're doing.