Scrapy, a fast high-level web crawling & scraping framework for Python.
Move scrapy/spider.py to scrapy/spiders/__init__.py
Julia Medinad3f576a816b8
diff --git a/docs/intro/tutorial.rst b/docs/intro/tutorial.rstindex 219616587..0d3c49750 100644--- a/docs/intro/tutorial.rst+++ b/docs/intro/tutorial.rst@@ -95,18 +95,18 @@ domain (or group of domains).They define an initial list of URLs to download, how to follow links, and howto parse the contents of pages to extract :ref:`items <topics-items>`.-To create a Spider, you must subclass :class:`scrapy.Spider <scrapy.spider.Spider>` and-define some attributes:+To create a Spider, you must subclass :class:`scrapy.Spider+<scrapy.spiders.Spider>` and define some attributes:-* :attr:`~scrapy.spider.Spider.name`: identifies the Spider. It must be+* :attr:`~scrapy.spiders.Spider.name`: identifies the Spider. It must beunique, that is, you can't set the same name for different Spiders.-* :attr:`~scrapy.spider.Spider.start_urls`: a list of URLs where the+* :attr:`~scrapy.spiders.Spider.start_urls`: a list of URLs where theSpider will begin to crawl from. The first pages downloaded will be thoselisted here. The subsequent URLs will be generated successively from datacontained in the start URLs.-* :meth:`~scrapy.spider.Spider.parse`: a method of the spider, which will+* :meth:`~scrapy.spiders.Spider.parse`: a method of the spider, which willbe called with the downloaded :class:`~scrapy.http.Response` object of eachstart URL. The response is passed to the method as the first and onlyargument.@@ -114,7 +114,7 @@ define some attributes:This method is responsible for parsing the response data and extractingscraped data (as scraped items) and more URLs to follow.- The :meth:`~scrapy.spider.Spider.parse` method is in charge of processing+ The :meth:`~scrapy.spiders.Spider.parse` method is in charge of processingthe response and returning scraped data (as :class:`~scrapy.item.Item`objects) and more URLs to follow (as :class:`~scrapy.http.Request` objects).@@ -178,7 +178,7 @@ them the ``parse`` method of the spider as their callback function.These Requests are scheduled, then executed, and :class:`scrapy.http.Response`objects are returned and then fed back to the spider, through the-:meth:`~scrapy.spider.Spider.parse` method.+:meth:`~scrapy.spiders.Spider.parse` method.Extracting Items----------------diff --git a/docs/topics/api.rst b/docs/topics/api.rstindex ce28b8bc1..e59fe9a58 100644--- a/docs/topics/api.rst+++ b/docs/topics/api.rst@@ -31,7 +31,7 @@ how you :ref:`configure the downloader middlewares.. class:: Crawler(spidercls, settings)The Crawler object must be instantiated with a- :class:`scrapy.spider.Spider` subclass and a+ :class:`scrapy.spiders.Spider` subclass and a:class:`scrapy.settings.Settings` object... attribute:: settingsdiff --git a/docs/topics/downloader-middleware.rst b/docs/topics/downloader-middleware.rstindex 5cb6c9824..03c5deffe 100644--- a/docs/topics/downloader-middleware.rst+++ b/docs/topics/downloader-middleware.rst@@ -91,7 +91,7 @@ more of the following methods::type request: :class:`~scrapy.http.Request` object:param spider: the spider for which this request is intended- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. method:: process_response(request, response, spider)@@ -118,7 +118,7 @@ more of the following methods::type response: :class:`~scrapy.http.Response` object:param spider: the spider for which this response is intended- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. method:: process_exception(request, exception, spider)@@ -149,7 +149,7 @@ more of the following methods::type exception: an ``Exception`` object:param spider: the spider for which this request is intended- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. _topics-downloader-middleware-ref:diff --git a/docs/topics/item-pipeline.rst b/docs/topics/item-pipeline.rstindex dd2d79989..f74400b4d 100644--- a/docs/topics/item-pipeline.rst+++ b/docs/topics/item-pipeline.rst@@ -36,7 +36,7 @@ Each item pipeline component is a Python class that must implement the following:type item: :class:`~scrapy.item.Item` object or a dict:param spider: the spider which scraped the item- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` objectAdditionally, they may also implement the following methods:@@ -45,14 +45,14 @@ Additionally, they may also implement the following methods:This method is called when the spider is opened.:param spider: the spider which was opened- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. method:: close_spider(self, spider)This method is called when the spider is closed.:param spider: the spider which was closed- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. method:: from_crawler(cls, crawler)diff --git a/docs/topics/leaks.rst b/docs/topics/leaks.rstindex 9d15ebe48..735137ea2 100644--- a/docs/topics/leaks.rst+++ b/docs/topics/leaks.rst@@ -92,7 +92,7 @@ subclasses):* :class:`scrapy.http.Response`* :class:`scrapy.item.Item`* :class:`scrapy.selector.Selector`-* :class:`scrapy.spider.Spider`+* :class:`scrapy.spiders.Spider`A real example--------------@@ -155,7 +155,7 @@ For this reason, that function has a ``ignore`` argument which can be used toignore a particular class (and all its subclases). Forexample, this won't show any live references to spiders::- >>> from scrapy.spider import Spider+ >>> from scrapy.spiders import Spider>>> prefs(ignore=Spider).. module:: scrapy.utils.trackrefdiff --git a/docs/topics/logging.rst b/docs/topics/logging.rstindex 2cb719998..1a3f5d69f 100644--- a/docs/topics/logging.rst+++ b/docs/topics/logging.rst@@ -94,7 +94,7 @@ path::Logging from Spiders====================-Scrapy provides a :data:`~scrapy.spider.Spider.logger` within each Spider+Scrapy provides a :data:`~scrapy.spiders.Spider.logger` within each Spiderinstance, that can be accessed and used like this::import scrapydiff --git a/docs/topics/request-response.rst b/docs/topics/request-response.rstindex 1d695a5f2..aa601f83a 100644--- a/docs/topics/request-response.rst+++ b/docs/topics/request-response.rst@@ -37,7 +37,7 @@ Request objectsrequest (once its downloaded) as its first parameter. For more informationsee :ref:`topics-request-response-ref-request-callback-arguments` below.If a Request doesn't specify a callback, the spider's- :meth:`~scrapy.spider.Spider.parse` method will be used.+ :meth:`~scrapy.spiders.Spider.parse` method will be used.Note that if exceptions are raised during processing, errback is called instead.:type callback: callablediff --git a/docs/topics/settings.rst b/docs/topics/settings.rstindex 26a6d762d..5917bea4e 100644--- a/docs/topics/settings.rst+++ b/docs/topics/settings.rst@@ -67,7 +67,7 @@ Example::Spiders (See the :ref:`topics-spiders` chapter for reference) can define theirown settings that will take precedence and override the project ones. They can-do so by setting their :attr:`scrapy.spider.Spider.custom_settings` attribute.+do so by setting their :attr:`scrapy.spiders.Spider.custom_settings` attribute.3. Project settings module--------------------------diff --git a/docs/topics/shell.rst b/docs/topics/shell.rstindex 3b875fec5..9c9411d6d 100644--- a/docs/topics/shell.rst+++ b/docs/topics/shell.rst@@ -74,7 +74,7 @@ Those objects are:* ``crawler`` - the current :class:`~scrapy.crawler.Crawler` object.* ``spider`` - the Spider which is known to handle the URL, or a- :class:`~scrapy.spider.Spider` object if there is no spider found for+ :class:`~scrapy.spiders.Spider` object if there is no spider found forthe current URL* ``request`` - a :class:`~scrapy.http.Request` object of the last fetcheddiff --git a/docs/topics/signals.rst b/docs/topics/signals.rstindex 85cf43c76..7ea9efe49 100644--- a/docs/topics/signals.rst+++ b/docs/topics/signals.rst@@ -74,7 +74,7 @@ item_scraped:type item: dict or :class:`~scrapy.item.Item` object:param spider: the spider which scraped the item- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object:param response: the response from where the item was scraped:type response: :class:`~scrapy.http.Response` object@@ -94,7 +94,7 @@ item_dropped:type item: dict or :class:`~scrapy.item.Item` object:param spider: the spider which scraped the item- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object:param response: the response from where the item was dropped:type response: :class:`~scrapy.http.Response` object@@ -116,7 +116,7 @@ spider_closedThis signal supports returning deferreds from their handlers.:param spider: the spider which has been closed- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object:param reason: a string which describes the reason why the spider was closed. Ifit was closed because the spider has completed scraping, the reason@@ -140,7 +140,7 @@ spider_openedThis signal supports returning deferreds from their handlers.:param spider: the spider which has been opened- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` objectspider_idle-----------@@ -164,7 +164,7 @@ spider_idleThis signal does not support returning deferreds from their handlers.:param spider: the spider which has gone idle- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` objectspider_error------------@@ -181,7 +181,7 @@ spider_error:type response: :class:`~scrapy.http.Response` object:param spider: the spider which raised the exception- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` objectrequest_scheduled-----------------@@ -198,7 +198,7 @@ request_scheduled:type request: :class:`~scrapy.http.Request` object:param spider: the spider that yielded the request- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` objectrequest_dropped-----------------@@ -215,7 +215,7 @@ request_dropped:type request: :class:`~scrapy.http.Request` object:param spider: the spider that yielded the request- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` objectresponse_received-----------------@@ -235,7 +235,7 @@ response_received:type request: :class:`~scrapy.http.Request` object:param spider: the spider for which the response is intended- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` objectresponse_downloaded-------------------@@ -254,6 +254,6 @@ response_downloaded:type request: :class:`~scrapy.http.Request` object:param spider: the spider for which the response is intended- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. _Failure: http://twistedmatrix.com/documents/current/api/twisted.python.failure.Failure.htmldiff --git a/docs/topics/spider-middleware.rst b/docs/topics/spider-middleware.rstindex 6e82333f5..84daaaa55 100644--- a/docs/topics/spider-middleware.rst+++ b/docs/topics/spider-middleware.rst@@ -81,7 +81,7 @@ following methods::type response: :class:`~scrapy.http.Response` object:param spider: the spider for which this response is intended- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. method:: process_spider_output(response, result, spider)@@ -102,7 +102,7 @@ following methods:or :class:`~scrapy.item.Item` objects:param spider: the spider whose result is being processed- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. method:: process_spider_exception(response, exception, spider)@@ -130,7 +130,7 @@ following methods::type exception: `Exception`_ object:param spider: the spider which raised the exception- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. method:: process_start_requests(start_requests, spider)@@ -157,7 +157,7 @@ following methods::type start_requests: an iterable of :class:`~scrapy.http.Request`:param spider: the spider to whom the start requests belong- :type spider: :class:`~scrapy.spider.Spider` object+ :type spider: :class:`~scrapy.spiders.Spider` object.. _Exception: https://docs.python.org/2/library/exceptions.html#exceptions.Exception@@ -272,7 +272,7 @@ OffsiteMiddlewareFilters out Requests for URLs outside the domains covered by the spider.This middleware filters out every request whose host names aren't in the- spider's :attr:`~scrapy.spider.Spider.allowed_domains` attribute.+ spider's :attr:`~scrapy.spiders.Spider.allowed_domains` attribute.When your spider returns a request for a domain not belonging to thosecovered by the spider, this middleware will log a debug message similar to@@ -287,7 +287,7 @@ OffsiteMiddlewarewill be printed (but only for the first request filtered).If the spider doesn't define an- :attr:`~scrapy.spider.Spider.allowed_domains` attribute, or the+ :attr:`~scrapy.spiders.Spider.allowed_domains` attribute, or theattribute is empty, the offsite middleware will allow all requests.If the request has the :attr:`~scrapy.http.Request.dont_filter` attributediff --git a/docs/topics/spiders.rst b/docs/topics/spiders.rstindex d2fdd61b8..025d527a6 100644--- a/docs/topics/spiders.rst+++ b/docs/topics/spiders.rst@@ -17,10 +17,10 @@ For spiders, the scraping cycle goes through something like this:those requests.The first requests to perform are obtained by calling the- :meth:`~scrapy.spider.Spider.start_requests` method which (by default)+ :meth:`~scrapy.spiders.Spider.start_requests` method which (by default)generates :class:`~scrapy.http.Request` for the URLs specified in the- :attr:`~scrapy.spider.Spider.start_urls` and the- :attr:`~scrapy.spider.Spider.parse` method as callback function for the+ :attr:`~scrapy.spiders.Spider.start_urls` and the+ :attr:`~scrapy.spiders.Spider.parse` method as callback function for theRequests.2. In the callback function, you parse the response (web page) and return either@@ -42,7 +42,7 @@ Even though this cycle applies (more or less) to any kind of spider, there aredifferent kinds of default spiders bundled into Scrapy for different purposes.We will talk about those types here.-.. module:: scrapy.spider+.. module:: scrapy.spiders:synopsis: Spiders base class, spider manager and spider middleware.. _topics-spiders-ref:@@ -319,8 +319,7 @@ with a ``TestItem`` declared in a ``myproject.items`` module::description = scrapy.Field()-.. module:: scrapy.spiders- :synopsis: Collection of generic spiders+.. currentmodule:: scrapy.spidersCrawlSpider-----------diff --git a/extras/qpsclient.py b/extras/qpsclient.pyindex 7a1baccca..bb83588dd 100644--- a/extras/qpsclient.py+++ b/extras/qpsclient.py@@ -7,7 +7,7 @@ usage:"""-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Requestdiff --git a/scrapy/__init__.py b/scrapy/__init__.pyindex 31ad2ff02..10ba9544f 100644--- a/scrapy/__init__.py+++ b/scrapy/__init__.py@@ -45,7 +45,7 @@ if twisted_version >= (11, 1, 0):optional_features.add('http11')# Declare top-level shortcuts-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Request, FormRequestfrom scrapy.selector import Selectorfrom scrapy.item import Item, Fielddiff --git a/scrapy/crawler.py b/scrapy/crawler.pyindex 161ca4614..e6f4b225f 100644--- a/scrapy/crawler.py+++ b/scrapy/crawler.py@@ -138,7 +138,7 @@ class CrawlerRunner(object)::param crawler_or_spidercls: already created crawler, or a spider classor spider's name inside the project to create it:type crawler_or_spidercls: :class:`~scrapy.crawler.Crawler` instance,- :class:`~scrapy.spider.Spider` subclass or string+ :class:`~scrapy.spiders.Spider` subclass or string:param list args: arguments to initialize the spiderdiff --git a/scrapy/shell.py b/scrapy/shell.pyindex 8f87fcb41..4142396ab 100644--- a/scrapy/shell.py+++ b/scrapy/shell.py@@ -17,7 +17,7 @@ from scrapy.exceptions import IgnoreRequest, ScrapyDeprecationWarningfrom scrapy.http import Request, Responsefrom scrapy.item import BaseItemfrom scrapy.settings import Settings-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.console import start_python_consolefrom scrapy.utils.misc import load_objectfrom scrapy.utils.response import open_in_browserdiff --git a/scrapy/spider.py b/scrapy/spiders/__init__.pysimilarity index 94%rename from scrapy/spider.pyrename to scrapy/spiders/__init__.pyindex 36623b6e2..c08bb964a 100644--- a/scrapy/spider.py+++ b/scrapy/spiders/__init__.py@@ -111,3 +111,7 @@ spiders = ObsoleteClass('it with your project settings"')+# Top-level imports+from scrapy.spiders.crawl import CrawlSpider, Rule+from scrapy.spiders.feed import XMLFeedSpider, CSVFeedSpider+from scrapy.spiders.sitemap import SitemapSpiderdiff --git a/scrapy/spiders/crawl.py b/scrapy/spiders/crawl.pyindex 7dc3dacd6..77551753e 100644--- a/scrapy/spiders/crawl.py+++ b/scrapy/spiders/crawl.py@@ -9,7 +9,7 @@ import copyfrom scrapy.http import Request, HtmlResponsefrom scrapy.utils.spider import iterate_spider_output-from scrapy.spider import Spider+from scrapy.spiders import Spiderdef identity(x):return xdiff --git a/scrapy/spiders/feed.py b/scrapy/spiders/feed.pyindex d83ee605e..06e212e1c 100644--- a/scrapy/spiders/feed.py+++ b/scrapy/spiders/feed.py@@ -4,7 +4,7 @@ for scraping from an XML feed.See documentation in docs/topics/spiders.rst"""-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.iterators import xmliter, csviterfrom scrapy.utils.spider import iterate_spider_outputfrom scrapy.selector import Selectordiff --git a/scrapy/spiders/init.py b/scrapy/spiders/init.pyindex 9c94a7b33..7717c8819 100644--- a/scrapy/spiders/init.py+++ b/scrapy/spiders/init.py@@ -1,4 +1,4 @@-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.spider import iterate_spider_outputclass InitSpider(Spider):@@ -20,8 +20,8 @@ class InitSpider(Spider):is called this spider is considered initialized. If you need to performseveral requests for initializing your spider, you can do so by usingdifferent callbacks. The only requirement is that the final callback- (of the last initialization request) must be self.initialized.-+ (of the last initialization request) must be self.initialized.+The default implementation calls self.initialized immediately, andmeans that no initialization is needed. This method should beoverridden only when you need to perform requests to initialize yourdiff --git a/scrapy/spiders/sitemap.py b/scrapy/spiders/sitemap.pyindex 90fb9fb4e..5aa0b944d 100644--- a/scrapy/spiders/sitemap.py+++ b/scrapy/spiders/sitemap.py@@ -1,7 +1,7 @@import reimport logging-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Request, XmlResponsefrom scrapy.utils.sitemap import Sitemap, sitemap_urls_from_robotsfrom scrapy.utils.gz import gunzip, is_gzippeddiff --git a/scrapy/utils/spider.py b/scrapy/utils/spider.pyindex 7ed2d0c3b..94b24f67e 100644--- a/scrapy/utils/spider.py+++ b/scrapy/utils/spider.py@@ -3,7 +3,7 @@ import inspectimport six-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.misc import arg_to_iterlogger = logging.getLogger(__name__)@@ -19,7 +19,7 @@ def iter_spider_classes(module):"""# this needs to be imported here until get rid of the spider manager# singleton in scrapy.spider.spiders- from scrapy.spider import Spider+ from scrapy.spiders import Spiderfor obj in six.itervalues(vars(module)):if inspect.isclass(obj) and \diff --git a/scrapy/utils/test.py b/scrapy/utils/test.pyindex ad4a6aa7c..bec9bdda9 100644--- a/scrapy/utils/test.py+++ b/scrapy/utils/test.py@@ -27,7 +27,7 @@ def get_crawler(spidercls=None, settings_dict=None):"""from scrapy.crawler import CrawlerRunnerfrom scrapy.settings import Settings- from scrapy.spider import Spider+ from scrapy.spiders import Spiderrunner = CrawlerRunner(Settings(settings_dict))return runner._create_crawler(spidercls or Spider)diff --git a/tests/spiders.py b/tests/spiders.pyindex c2956d741..516062929 100644--- a/tests/spiders.py+++ b/tests/spiders.py@@ -5,7 +5,7 @@ Some spiders used for testing and benchmarkingimport timefrom six.moves.urllib.parse import urlencode-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Requestfrom scrapy.item import Itemfrom scrapy.linkextractors import LinkExtractordiff --git a/tests/test_commands.py b/tests/test_commands.pyindex b95d0b0cc..7c10faf0c 100644--- a/tests/test_commands.py+++ b/tests/test_commands.py@@ -158,7 +158,7 @@ class MySpider(scrapy.Spider):fname = abspath(join(tmpdir, 'myspider.py'))with open(fname, 'w') as f:f.write("""-from scrapy.spider import Spider+from scrapy.spiders import Spider""")p = self.proc('runspider', fname)log = p.stderr.read()diff --git a/tests/test_contracts.py b/tests/test_contracts.pyindex d7732f55d..1cea2afb7 100644--- a/tests/test_contracts.py+++ b/tests/test_contracts.py@@ -2,7 +2,7 @@ from unittest import TextTestResultfrom twisted.trial import unittest-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Requestfrom scrapy.item import Item, Fieldfrom scrapy.contracts import ContractsManagerdiff --git a/tests/test_downloader_handlers.py b/tests/test_downloader_handlers.pyindex 62fc280ee..df038aa88 100644--- a/tests/test_downloader_handlers.py+++ b/tests/test_downloader_handlers.py@@ -24,7 +24,7 @@ from scrapy.core.downloader.handlers.http11 import HTTP11DownloadHandlerfrom scrapy.core.downloader.handlers.s3 import S3DownloadHandlerfrom scrapy.core.downloader.handlers.ftp import FTPDownloadHandler-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Requestfrom scrapy.settings import Settingsfrom scrapy import optional_featuresdiff --git a/tests/test_downloadermiddleware.py b/tests/test_downloadermiddleware.pyindex 282035f5c..257eab609 100644--- a/tests/test_downloadermiddleware.py+++ b/tests/test_downloadermiddleware.py@@ -2,7 +2,7 @@ from twisted.trial.unittest import TestCasefrom twisted.python.failure import Failurefrom scrapy.http import Request, Response-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.core.downloader.middleware import DownloaderMiddlewareManagerfrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_downloadermiddleware_ajaxcrawlable.py b/tests/test_downloadermiddleware_ajaxcrawlable.pyindex 11de6e22d..67c57778d 100644--- a/tests/test_downloadermiddleware_ajaxcrawlable.py+++ b/tests/test_downloadermiddleware_ajaxcrawlable.py@@ -1,7 +1,7 @@import unittestfrom scrapy.downloadermiddlewares.ajaxcrawl import AjaxCrawlMiddleware-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Request, HtmlResponse, Responsefrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_downloadermiddleware_cookies.py b/tests/test_downloadermiddleware_cookies.pyindex 7f491f258..996b8c388 100644--- a/tests/test_downloadermiddleware_cookies.py+++ b/tests/test_downloadermiddleware_cookies.py@@ -2,7 +2,7 @@ from unittest import TestCaseimport refrom scrapy.http import Response, Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.downloadermiddlewares.cookies import CookiesMiddlewarediff --git a/tests/test_downloadermiddleware_decompression.py b/tests/test_downloadermiddleware_decompression.pyindex 7aca415ef..9143611fc 100644--- a/tests/test_downloadermiddleware_decompression.py+++ b/tests/test_downloadermiddleware_decompression.py@@ -1,7 +1,7 @@from unittest import TestCase, mainfrom scrapy.http import Response, XmlResponsefrom scrapy.downloadermiddlewares.decompression import DecompressionMiddleware-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom tests import get_testdatafrom scrapy.utils.test import assert_samelinesdiff --git a/tests/test_downloadermiddleware_defaultheaders.py b/tests/test_downloadermiddleware_defaultheaders.pyindex 26520a20a..75d8a1921 100644--- a/tests/test_downloadermiddleware_defaultheaders.py+++ b/tests/test_downloadermiddleware_defaultheaders.py@@ -3,7 +3,7 @@ import sixfrom scrapy.downloadermiddlewares.defaultheaders import DefaultHeadersMiddlewarefrom scrapy.http import Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_downloadermiddleware_downloadtimeout.py b/tests/test_downloadermiddleware_downloadtimeout.pyindex 282d10829..446a99f36 100644--- a/tests/test_downloadermiddleware_downloadtimeout.py+++ b/tests/test_downloadermiddleware_downloadtimeout.py@@ -1,7 +1,7 @@import unittestfrom scrapy.downloadermiddlewares.downloadtimeout import DownloadTimeoutMiddleware-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Requestfrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_downloadermiddleware_httpauth.py b/tests/test_downloadermiddleware_httpauth.pyindex cef65b336..c30fa97c6 100644--- a/tests/test_downloadermiddleware_httpauth.py+++ b/tests/test_downloadermiddleware_httpauth.py@@ -2,7 +2,7 @@ import unittestfrom scrapy.http import Requestfrom scrapy.downloadermiddlewares.httpauth import HttpAuthMiddleware-from scrapy.spider import Spider+from scrapy.spiders import Spiderclass TestSpider(Spider):http_user = 'foo'diff --git a/tests/test_downloadermiddleware_httpcache.py b/tests/test_downloadermiddleware_httpcache.pyindex ac954cc15..47d057e3f 100644--- a/tests/test_downloadermiddleware_httpcache.py+++ b/tests/test_downloadermiddleware_httpcache.py@@ -8,7 +8,7 @@ from contextlib import contextmanagerimport pytestfrom scrapy.http import Response, HtmlResponse, Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.settings import Settingsfrom scrapy.exceptions import IgnoreRequestfrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_downloadermiddleware_httpcompression.py b/tests/test_downloadermiddleware_httpcompression.pyindex 98df6d608..a18994ef3 100644--- a/tests/test_downloadermiddleware_httpcompression.py+++ b/tests/test_downloadermiddleware_httpcompression.py@@ -3,7 +3,7 @@ from unittest import TestCasefrom os.path import join, abspath, dirnamefrom gzip import GzipFile-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Response, Request, HtmlResponsefrom scrapy.downloadermiddlewares.httpcompression import HttpCompressionMiddlewarefrom tests import tests_datadirdiff --git a/tests/test_downloadermiddleware_httpproxy.py b/tests/test_downloadermiddleware_httpproxy.pyindex 90609879c..191664076 100644--- a/tests/test_downloadermiddleware_httpproxy.py+++ b/tests/test_downloadermiddleware_httpproxy.py@@ -5,7 +5,7 @@ from twisted.trial.unittest import TestCase, SkipTestfrom scrapy.downloadermiddlewares.httpproxy import HttpProxyMiddlewarefrom scrapy.exceptions import NotConfiguredfrom scrapy.http import Response, Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderspider = Spider('foo')diff --git a/tests/test_downloadermiddleware_redirect.py b/tests/test_downloadermiddleware_redirect.pyindex 3f299f258..7e88e71af 100644--- a/tests/test_downloadermiddleware_redirect.py+++ b/tests/test_downloadermiddleware_redirect.py@@ -1,7 +1,7 @@import unittestfrom scrapy.downloadermiddlewares.redirect import RedirectMiddleware, MetaRefreshMiddleware-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.exceptions import IgnoreRequestfrom scrapy.http import Request, Response, HtmlResponsefrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_downloadermiddleware_retry.py b/tests/test_downloadermiddleware_retry.pyindex 969452cfb..c0381e144 100644--- a/tests/test_downloadermiddleware_retry.py+++ b/tests/test_downloadermiddleware_retry.py@@ -7,7 +7,7 @@ from twisted.internet.error import TimeoutError, DNSLookupError, \from scrapy import optional_featuresfrom scrapy.downloadermiddlewares.retry import RetryMiddlewarefrom scrapy.xlib.tx import ResponseFailed-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Request, Responsefrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_downloadermiddleware_stats.py b/tests/test_downloadermiddleware_stats.pyindex 64f2d0786..fb46ccff6 100644--- a/tests/test_downloadermiddleware_stats.py+++ b/tests/test_downloadermiddleware_stats.py@@ -2,7 +2,7 @@ from unittest import TestCasefrom scrapy.downloadermiddlewares.stats import DownloaderStatsfrom scrapy.http import Request, Response-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_downloadermiddleware_useragent.py b/tests/test_downloadermiddleware_useragent.pyindex ddbb8f3ac..741c8de76 100644--- a/tests/test_downloadermiddleware_useragent.py+++ b/tests/test_downloadermiddleware_useragent.py@@ -1,6 +1,6 @@from unittest import TestCase-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Requestfrom scrapy.downloadermiddlewares.useragent import UserAgentMiddlewarefrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_engine.py b/tests/test_engine.pyindex bbb94fd58..d7ad88abb 100644--- a/tests/test_engine.py+++ b/tests/test_engine.py@@ -22,7 +22,7 @@ from scrapy import signalsfrom scrapy.utils.test import get_crawlerfrom scrapy.xlib.pydispatch import dispatcherfrom tests import tests_datadir-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.item import Item, Fieldfrom scrapy.linkextractors import LinkExtractorfrom scrapy.http import Requestdiff --git a/tests/test_logformatter.py b/tests/test_logformatter.pyindex 8446fd646..ec42ef8ab 100644--- a/tests/test_logformatter.py+++ b/tests/test_logformatter.py@@ -1,6 +1,6 @@import unittest-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.http import Request, Responsefrom scrapy.item import Item, Fieldfrom scrapy.logformatter import LogFormatterdiff --git a/tests/test_pipeline_media.py b/tests/test_pipeline_media.pyindex 24ba9d64a..7217eee90 100644--- a/tests/test_pipeline_media.py+++ b/tests/test_pipeline_media.py@@ -6,7 +6,7 @@ from twisted.internet import reactorfrom twisted.internet.defer import Deferred, inlineCallbacksfrom scrapy.http import Request, Response-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.request import request_fingerprintfrom scrapy.pipelines.media import MediaPipelinefrom scrapy.utils.signal import disconnect_alldiff --git a/tests/test_spider.py b/tests/test_spider.pyindex f771399ca..f2dfd2dce 100644--- a/tests/test_spider.py+++ b/tests/test_spider.py@@ -7,11 +7,10 @@ from testfixtures import LogCapturefrom twisted.trial import unittestfrom scrapy import signals-from scrapy.spider import Spider, BaseSpiderfrom scrapy.settings import Settingsfrom scrapy.http import Request, Response, TextResponse, XmlResponse, HtmlResponsefrom scrapy.spiders.init import InitSpider-from scrapy.spiders import CrawlSpider, Rule, XMLFeedSpider, \+from scrapy.spiders import Spider, BaseSpider, CrawlSpider, Rule, XMLFeedSpider, \CSVFeedSpider, SitemapSpiderfrom scrapy.linkextractors import LinkExtractorfrom scrapy.exceptions import ScrapyDeprecationWarning@@ -116,7 +115,7 @@ class SpiderTest(unittest.TestCase):def test_log(self):spider = self.spider_class('example.com')- with mock.patch('scrapy.spider.Spider.logger') as mock_logger:+ with mock.patch('scrapy.spiders.Spider.logger') as mock_logger:spider.log('test log msg', 'INFO')mock_logger.log.assert_called_once_with('INFO', 'test log msg')diff --git a/tests/test_spiderloader/__init__.py b/tests/test_spiderloader/__init__.pyindex 42f2f29b3..7cb5e299b 100644--- a/tests/test_spiderloader/__init__.py+++ b/tests/test_spiderloader/__init__.py@@ -6,7 +6,7 @@ from zope.interface.verify import verifyObjectfrom twisted.trial import unittest-# ugly hack to avoid cyclic imports of scrapy.spider when running this test+# ugly hack to avoid cyclic imports of scrapy.spiders when running this test# alonefrom scrapy.interfaces import ISpiderLoaderfrom scrapy.spiderloader import SpiderLoaderdiff --git a/tests/test_spiderloader/test_spiders/spider0.py b/tests/test_spiderloader/test_spiders/spider0.pyindex f1f19a1eb..75a90794e 100644--- a/tests/test_spiderloader/test_spiders/spider0.py+++ b/tests/test_spiderloader/test_spiders/spider0.py@@ -1,4 +1,4 @@-from scrapy.spider import Spider+from scrapy.spiders import Spiderclass Spider0(Spider):allowed_domains = ["scrapy1.org", "scrapy3.org"]diff --git a/tests/test_spiderloader/test_spiders/spider1.py b/tests/test_spiderloader/test_spiders/spider1.pyindex 16a533ca2..76efddc7f 100644--- a/tests/test_spiderloader/test_spiders/spider1.py+++ b/tests/test_spiderloader/test_spiders/spider1.py@@ -1,4 +1,4 @@-from scrapy.spider import Spider+from scrapy.spiders import Spiderclass Spider1(Spider):name = "spider1"diff --git a/tests/test_spiderloader/test_spiders/spider2.py b/tests/test_spiderloader/test_spiders/spider2.pyindex 4af6f7c41..0badd8437 100644--- a/tests/test_spiderloader/test_spiders/spider2.py+++ b/tests/test_spiderloader/test_spiders/spider2.py@@ -1,4 +1,4 @@-from scrapy.spider import Spider+from scrapy.spiders import Spiderclass Spider2(Spider):name = "spider2"diff --git a/tests/test_spiderloader/test_spiders/spider3.py b/tests/test_spiderloader/test_spiders/spider3.pyindex b3e5f3da7..d406f2d4f 100644--- a/tests/test_spiderloader/test_spiders/spider3.py+++ b/tests/test_spiderloader/test_spiders/spider3.py@@ -1,4 +1,4 @@-from scrapy.spider import Spider+from scrapy.spiders import Spiderclass Spider3(Spider):name = "spider3"diff --git a/tests/test_spidermiddleware_depth.py b/tests/test_spidermiddleware_depth.pyindex 5317795a3..a3cdc0114 100644--- a/tests/test_spidermiddleware_depth.py+++ b/tests/test_spidermiddleware_depth.py@@ -2,7 +2,7 @@ from unittest import TestCasefrom scrapy.spidermiddlewares.depth import DepthMiddlewarefrom scrapy.http import Response, Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.statscollectors import StatsCollectorfrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_spidermiddleware_httperror.py b/tests/test_spidermiddleware_httperror.pyindex 5cd2c2566..a64400482 100644--- a/tests/test_spidermiddleware_httperror.py+++ b/tests/test_spidermiddleware_httperror.py@@ -7,7 +7,7 @@ from twisted.internet import deferfrom scrapy.utils.test import get_crawlerfrom tests.mockserver import MockServerfrom scrapy.http import Response, Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.spidermiddlewares.httperror import HttpErrorMiddleware, HttpErrorfrom scrapy.settings import Settingsdiff --git a/tests/test_spidermiddleware_offsite.py b/tests/test_spidermiddleware_offsite.pyindex 296e8b1a3..f88c806d7 100644--- a/tests/test_spidermiddleware_offsite.py+++ b/tests/test_spidermiddleware_offsite.py@@ -3,7 +3,7 @@ from unittest import TestCasefrom six.moves.urllib.parse import urlparsefrom scrapy.http import Response, Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.spidermiddlewares.offsite import OffsiteMiddlewarefrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_spidermiddleware_referer.py b/tests/test_spidermiddleware_referer.pyindex f2815ebd3..d773ea8d3 100644--- a/tests/test_spidermiddleware_referer.py+++ b/tests/test_spidermiddleware_referer.py@@ -1,7 +1,7 @@from unittest import TestCasefrom scrapy.http import Response, Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.spidermiddlewares.referer import RefererMiddlewarediff --git a/tests/test_spidermiddleware_urllength.py b/tests/test_spidermiddleware_urllength.pyindex 1ef22ea07..dca868ecf 100644--- a/tests/test_spidermiddleware_urllength.py+++ b/tests/test_spidermiddleware_urllength.py@@ -2,7 +2,7 @@ from unittest import TestCasefrom scrapy.spidermiddlewares.urllength import UrlLengthMiddlewarefrom scrapy.http import Response, Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderclass TestUrlLengthMiddleware(TestCase):diff --git a/tests/test_spiderstate.py b/tests/test_spiderstate.pyindex 1ddce4b99..d83015bd9 100644--- a/tests/test_spiderstate.py+++ b/tests/test_spiderstate.py@@ -3,7 +3,7 @@ from datetime import datetimefrom twisted.trial import unittestfrom scrapy.extensions.spiderstate import SpiderState-from scrapy.spider import Spider+from scrapy.spiders import Spiderclass SpiderStateTest(unittest.TestCase):diff --git a/tests/test_stats.py b/tests/test_stats.pyindex 34f72736c..5c7c0e6bb 100644--- a/tests/test_stats.py+++ b/tests/test_stats.py@@ -1,6 +1,6 @@import unittest-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.statscollectors import StatsCollector, DummyStatsCollectorfrom scrapy.utils.test import get_crawlerdiff --git a/tests/test_toplevel.py b/tests/test_toplevel.pyindex 17cf82213..e9f220092 100644--- a/tests/test_toplevel.py+++ b/tests/test_toplevel.py@@ -21,7 +21,7 @@ class ToplevelTestCase(TestCase):self.assertIs(scrapy.FormRequest, FormRequest)def test_spider_shortcut(self):- from scrapy.spider import Spider+ from scrapy.spiders import Spiderself.assertIs(scrapy.Spider, Spider)def test_selector_shortcut(self):diff --git a/tests/test_utils_reqser.py b/tests/test_utils_reqser.pyindex 4ddc2f472..9139c0ad0 100644--- a/tests/test_utils_reqser.py+++ b/tests/test_utils_reqser.py@@ -1,7 +1,7 @@import unittestfrom scrapy.http import Request-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.reqser import request_to_dict, request_from_dictclass RequestSerializationTest(unittest.TestCase):diff --git a/tests/test_utils_url.py b/tests/test_utils_url.pyindex 959760068..860c76bae 100644--- a/tests/test_utils_url.py+++ b/tests/test_utils_url.py@@ -1,6 +1,6 @@import unittest-from scrapy.spider import Spider+from scrapy.spiders import Spiderfrom scrapy.utils.url import url_is_from_any_domain, url_is_from_spider, canonicalize_url__doctests__ = ['scrapy.utils.url']