What is wrong with python?

from scrapy.cmdline import execute
import sys

if __name__ == "__main__":
    if sys.argv[1] == "xiaomiquan":
        execute("scrapy crawl %s" % sys.argv[1].split())
    elif sys.argv[1] == "reportapp":
        execute("scrapy crawl %s" % sys.argv[1].split())
    elif sys.argv[1] == "baidusearch":
        execute("scrapy crawl %s" % sys.argv[1].split())

Traceback (most recent call last):
  File "main.py", line 6, in <module>
    execute("scrapy crawl %s" % sys.argv[1].split())
  File "/home/shenjianlin/.local/lib/python3.4/site-packages/scrapy/cmdline.py", line 130, in execute
    cmdname = _pop_command_name(argv)
  File "/home/shenjianlin/.local/lib/python3.4/site-packages/scrapy/cmdline.py", line 58, in _pop_command_name
    del argv[i]
TypeError: "str" object doesn"t support item deletion

Sep.27,2021

what kind of fancy operation is this?
script running crawler, please use the official api, not to change cmdline.
from-a-script" rel=" nofollow noreferrer "> https://doc.scrapy.org/en/lat.


error message is not very clear. Str object does not support element deletion. The sys.argv [1] you passed is an one-step delete operation in scrapy under the use of str,. Use api to read the documents as you said upstairs, don't cmd

Menu