SoFunction
Updated on 2025-03-01

scrapyd setting issue

Use cases:

import requests
adder='http://127.0.0.1:6800'
data = {
    'project':'v1',
    'version':'12379',
    'setting':['ROBOTSTXT_OBEY=True','CONCURRENT_REQUESTS=32']
}
resp = (adder,data=data)

Problem solving ideas:

In the document version 1.2:

◦setting (string, optional) - a Scrapy setting to use when running the spider

setting is a string, so what should multiple strings be?

By source codesite-packages/scrapyd/

class Schedule(WsResource):
  def render_POST(self, txrequest):
    args = native_stringify_dict(copy(), keys_only=False)
    settings = ('setting', [])
    settings = dict(('=', 1) for x in settings)
    args = dict((k, v[0]) for k, v in ())
    project = ('project')
    spider = ('spider')
    version = ('_version', '')
    spiders = get_spider_list(project, version=version)
    if not spider in spiders:
      return {"status": "error", "message": "spider '%s' not found" % spider}
    args['settings'] = settings
    jobid = ('jobid', uuid.uuid1().hex)
    args['_job'] = jobid
    (project, spider, **args)
    return {"node_name": , "status": "ok", "jobid": jobid}

It can be found that setting is a list object here, and the elements inside are characters, and the string must contain the = symbol.

We try to pass insetting:['DEBUG=True','HOST_NAME=axdda']

The result is really OK. For more complex settings, I will study them next time if you need them.

Summarize

The above is the scrapyd setting introduced by the editor to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!
If you think this article is helpful to you, please reprint it. Please indicate the source, thank you!