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 showFrom scrapy project directory into modules
CodePudding user response:
But I changed to weibohot. The items I can't alsoCodePudding 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 itemsCodePudding user response:
Well I didn't say clearFrom 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 *