Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

use "import scrapy" in templates

Mikhail Korobov4ddad88d6f8d
diff --git a/scrapy/templates/project/module/items.py.tmpl b/scrapy/templates/project/module/items.py.tmpl
index aab8ca9b3..826c385e8 100644
--- a/scrapy/templates/project/module/items.py.tmpl
+++ b/scrapy/templates/project/module/items.py.tmpl
@@ -3,9 +3,9 @@
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html
-from scrapy.item import Item, Field
+import scrapy
-class ${ProjectName}Item(Item):
+class ${ProjectName}Item(scrapy.Item):
# define the fields for your item here like:
- # name = Field()
+ # name = scrapy.Field()
pass
diff --git a/scrapy/templates/spiders/basic.tmpl b/scrapy/templates/spiders/basic.tmpl
index 0a1fbd7fd..da5c57a39 100644
--- a/scrapy/templates/spiders/basic.tmpl
+++ b/scrapy/templates/spiders/basic.tmpl
@@ -1,6 +1,6 @@
-from scrapy.spider import Spider
+import scrapy
-class $classname(Spider):
+class $classname(scrapy.Spider):
name = "$name"
allowed_domains = ["$domain"]
start_urls = (
@@ -8,4 +8,4 @@ class $classname(Spider):
)
def parse(self, response):
- pass
+ pass
diff --git a/scrapy/templates/spiders/crawl.tmpl b/scrapy/templates/spiders/crawl.tmpl
index 82c27d7f4..25e84f940 100644
--- a/scrapy/templates/spiders/crawl.tmpl
+++ b/scrapy/templates/spiders/crawl.tmpl
@@ -1,4 +1,4 @@
-from scrapy.selector import Selector
+import scrapy
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.contrib.spiders import CrawlSpider, Rule
from $project_name.items import ${ProjectName}Item
@@ -13,7 +13,7 @@ class $classname(CrawlSpider):
)
def parse_item(self, response):
- sel = Selector(response)
+ sel = scrapy.Selector(response)
i = ${ProjectName}Item()
#i['domain_id'] = sel.xpath('//input[@id="sid"]/@value').extract()
#i['name'] = sel.xpath('//div[@id="name"]').extract()