Home > other >  Questions about the item import scrapy creeper
Questions about the item import scrapy creeper

Time:03-23

 import scrapy 
from .. The items import WeibohotItem

The class wbspider (scrapy. Spiders) :
Name='wb'
Allowed_domains=[' weibo.com ']
Start_url=[' https://s.weibo.com/top/summary ']

Def parse (self, response) :
News=response. Xpath ('//tbody tr)

For the new in the news:
The item=WeibohotItem ()
Item. [' ranking]=new xpath ('/td/@ '). The extract ()
Item. [' title ']=new xpath ('/td/@/a '). The extract ()
Item. [' hot ']=new xpath ('/td/@/span '). The extract ()

Yield item


The item
 import scrapy 

The class WeibohotItem (scrapy. Item) :
# define the fields for the item here like:
# name=scrapy. Field ()
Ranking=scrapy. Field ()
Title=scrapy. Field ()
Hot=scrapy. Field ()



Why import item still complains?

CodePudding user response:

from .. Too show

From scrapy project directory into modules

CodePudding user response:

But I changed to weibohot. The items I can't also

CodePudding user response:

Edit in the Run configurations inside to see where is your working directory, python import custom classes began to find your working directory path, to see you here working directory should be below the practice, all you change the import to: weibohot. Weibohot. Try the items

CodePudding user response:

Well I didn't say clear

From scrapy project directory into the module means:

You pycharm File, open a File, in weibohot project, for the root directory of the current File, open the project,

Then the from weibohot. Items import *
  • Related