错误:
ImportError: No module named items
程序:
items.py代码:
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
from scrapy.item import Item, Field
class XsItem(Item):
# define the fields for your item here like:
# name = Field()
url = Field()
xs.py代码:
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
from xs.items import XsItem
class XsSpider(CrawlSpider):
name = 'xs'
allowed_domains = ['bbs.uc.cn']
start_urls = ['http://bbs.uc.cn']
rules = (
Rule(SgmlLinkExtractor(allow=('\thread-\d+-\d-\d.html', )),
callback='parse_page', follow=True),
)
def parse_page(self, response):
item = XsItem()
sel = Selector(response)
item['url'] = response.url
return item
ImportError: No module named items
程序:
items.py代码:
# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
from scrapy.item import Item, Field
class XsItem(Item):
# define the fields for your item here like:
# name = Field()
url = Field()
xs.py代码:
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import Selector
from xs.items import XsItem
class XsSpider(CrawlSpider):
name = 'xs'
allowed_domains = ['bbs.uc.cn']
start_urls = ['http://bbs.uc.cn']
rules = (
Rule(SgmlLinkExtractor(allow=('\thread-\d+-\d-\d.html', )),
callback='parse_page', follow=True),
)
def parse_page(self, response):
item = XsItem()
sel = Selector(response)
item['url'] = response.url
return item