Problem description
In items. Py
, customize the item method.
# Define here the models for your scraped items
#
# See documentation in:
# https://docs.scrapy.org/en/latest/topics/items.html
import scrapy
class MyspiderItem(scrapy.Item):
# define the fields for your item here like:
name = scrapy.Field()
title = scrapy.Field()
desc = scrapy.Field()
RD_achievements = scrapy.Field()
We need to introduce this method into the sweep, which is the item method defined by ourselves in the sweep, but we need to reference it in the spider in the sweep, so we need to add a string of code to change our introduction method.
Error reported in pychart from myspyder.items import itcastitem
:
Original import method:
import scrapy
from crawlAdvanced.myspider.myspider.items import MyspiderItem
"""
scrapy crawl itcast --nolog
"""
from crawlAdvanced.myspider.myspider.items import MyspiderItem ModuleNotFoundError: No module named 'crawlAdvanced'
Solution 1
Change from myspider.items import myitem
to from.. items import myitem
In a package, peers use .
and parents use ..
Maybe the computer doesn’t know which file you’re talking about. After all, the two file names are the same( I don’t understand. I hope the boss can correct it!)
scrapy startproject mySpider
scrapy crawl mySpider
scrapy crawl mySpider -o teachers.json
Solution 2
If the error is still reported, you can refer to the following methods: (my error is solved by using the above method)
# -*- coding: utf-8 -*-
#The original python method of introducing scrapy class is wrong, please reintroduce it with this method
from __future__ import absolute_import
# is the above code
import scrapy
from selenium import webdriver
from scrapy_splash import SplashMiddleware
from scrapy_splash import SplashRequest
import pymysql
from ..item360 import Jc360Item
Read More:
- How to Solve Pychart configuration import torch error
- PyCharm: How to Solve Tensorflow_datasets Import Error
- How to Solve Error “ImportError: cannot import name imsave“
- How to Solve M1 chip import numpy Error
- How to Solve Python ImportError: cannot import name UnrewindableBodyError
- How to Solve Python Pandas Read or Import Files Error
- [Mac M1] How to Solve import wordcloud Error: ModuleNotFoundError: No module named ‘wordcloud‘
- [Solved] Pychart breakpoint error: frames are not available
- [Solved] OpenCV Import Error: ImportError: numpy.core.multiarray failed to import
- Raspberry pie import opencv error: ImportError: numpy.core.multiarray failed to import
- How to Solve Python Xlwt ValueError: More than 4094 XFs (styles)
- Solve the problem of error reporting from scipy.misc import imread & imresize in Python
- Python: How to Solve error While importing windpy
- How to Solve Python AttributeError: ‘dict’ object has no attribute ‘item’
- How to Solve wikiextractor Extract Wikipedia Corpus Error
- How to Solve Python Importerror: DLL load failed: unable to find the specified program using tensorflow
- Keras import package error: importerror: cannot import name ‘get_ config‘
- How to Solve Turtle_tf Error in ROS
- How to Solve jupyter notebook Read CSV files Error
- How to Solve Yolox Training C Disk Full Issue