Create a scrapy project starting with a number

In the scrapy startproject xxx command, the project name can only contain numbers, letters, and underscores, and start with a letter , and cannot contain a minus sign .

Create a scrapy project that starts with a number, sort it when you look at it, and know which one to write first and which one to write later.

You can first create a project that conforms to the naming rules, and then change it to scrapy_number_xxx (update, you can directly use this name to create a project, it conforms to the rules, and you don’t need to replace the old names in each file after creation) , and then scrapy. Old names in cfg and settings.py are replaced with new ones. If you opened the project with pycharm before changing the name, you also need to modify the contents in the .idea folder, and also replace the old name with the new name.

You cannot change the project name to a number - scrapy_xxx, because the crawler code needs to import the data structure defined by itself from items.py (that is, the class that inherits from scrapy.Item), and in the from xxx import xxx statement, the package name cannot be Begins with a number and cannot contain a minus sign .

The project name cannot contain Chinese, because running the scrapy project needs to be run on the terminal, and the default encoding of the terminal of the Chinese windows system is GBK (as shown in the figure), which causes the Chinese to be garbled after entering the running command containing Chinese in the terminal. , the project failed to start.

In this way, it actually starts with scrapy_number_ . Although it does not start with a number, it has the same effect as starting with a number. When you look at it, it is sorted by name by default, and the prefixes of the names of different projects are the same, all of which are scrapy_ . Then sort by the numbers after scrapy_ . You can also change it to your favorite prefix.

Guess you like

Origin blog.csdn.net/fj_changing/article/details/123729268