Reputation: 131
I'm trying to build a Scrapy spider from the very beginning. I managed to generate a spider using scrapy genspider name_of_spider
, but when I typed scrapy shell
, I received the following result.
Note that when I used another spider of mine to run scrapy crawl spider_name
, that spider worked just fine. However, I couldn't launch that scrapy shell either.
(venv) jacquelinewong@Jacquelines-MBP rent_apt % scrapy shell
2020-05-29 09:29:12 [scrapy.utils.log] INFO: Scrapy 2.0.1 started (bot: rent_apt)
2020-05-29 09:29:12 [scrapy.utils.log] INFO: Versions: lxml 4.2.1.0, libxml2 2.9.8, cssselect 1.1.0, parsel 1.5.2, w3lib 1.21.0, Twisted 20.3.0, Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) - [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)], pyOpenSSL 18.0.0 (OpenSSL 1.1.1g 21 Apr 2020), cryptography 2.9.2, Platform Darwin-19.3.0-x86_64-i386-64bit
2020-05-29 09:29:12 [scrapy.utils.log] DEBUG: Using reactor: twisted.internet.selectreactor.SelectReactor
2020-05-29 09:29:12 [scrapy.crawler] INFO: Overridden settings:
{'BOT_NAME': 'rent_apt',
'DUPEFILTER_CLASS': 'scrapy.dupefilters.BaseDupeFilter',
'LOGSTATS_INTERVAL': 0,
'NEWSPIDER_MODULE': 'rent_apt.spiders',
'ROBOTSTXT_OBEY': True,
'SPIDER_MODULES': ['rent_apt.spiders']}
2020-05-29 09:29:12 [scrapy.extensions.telnet] INFO: Telnet Password: eb3c5554d18c822b
2020-05-29 09:29:12 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
'scrapy.extensions.telnet.TelnetConsole',
'scrapy.extensions.memusage.MemoryUsage']
2020-05-29 09:29:12 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.robotstxt.RobotsTxtMiddleware',
'scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
'scrapy.downloadermiddlewares.retry.RetryMiddleware',
'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
'scrapy.downloadermiddlewares.stats.DownloaderStats']
2020-05-29 09:29:12 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
'scrapy.spidermiddlewares.referer.RefererMiddleware',
'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
'scrapy.spidermiddlewares.depth.DepthMiddleware']
2020-05-29 09:29:12 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2020-05-29 09:29:12 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2020-05-29 09:29:13 [py.warnings] WARNING: /Users/jacquelinewong/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py:763: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
warn("Attempting to work in a virtualenv. If you encounter problems, please "
[s] Available Scrapy objects:
[s] scrapy scrapy module (contains scrapy.Request, scrapy.Selector, etc)
[s] crawler <scrapy.crawler.Crawler object at 0x114358240>
[s] item {}
[s] settings <scrapy.settings.Settings object at 0x114354e80>
[s] Useful shortcuts:
[s] fetch(url[, redirect=True]) Fetch URL and update local objects (by default, redirects are followed)
[s] fetch(req) Fetch a scrapy.Request and update local objects
[s] shelp() Shell help (print this help)
[s] view(response) View response in a browser
In [1]: response
In [2]:
If the shell works fine, it should return a 200
message.
In [2]: response
Out[2]: <200 http://quotes.toscrape.com/>
Please help me out to debug this!
Upvotes: 1
Views: 161
Reputation: 131
It turned out I had a timeout issue. According to this post, reasons for requests getting timed out are:
Once I tried to fetch another url, the shell works!
In [1]: fetch('https://www.apartments.com/manhattan-ny/')
2020-05-29 09:53:28 [scrapy.core.engine] INFO: Spider opened
2020-05-29 09:56:28 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET https://www.apartments.com/robots.txt> (failed 1 times): User timeout caused connection failure: Getting https://www.apartments.com/robots.txt took longer than 180.0 seconds..
2020-05-29 09:59:28 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET https://www.apartments.com/robots.txt> (failed 2 times): User timeout caused connection failure: Getting https://www.apartments.com/robots.txt took longer than 180.0 seconds..
2020-05-29 10:02:28 [scrapy.downloadermiddlewares.retry] ERROR: Gave up retrying <GET https://www.apartments.com/robots.txt> (failed 3 times): User timeout caused connection failure: Getting https://www.apartments.com/robots.txt took longer than 180.0 seconds..
2020-05-29 10:02:28 [scrapy.downloadermiddlewares.robotstxt] ERROR: Error downloading <GET https://www.apartments.com/robots.txt>: User timeout caused connection failure: Getting https://www.apartments.com/robots.txt took longer than 180.0 seconds..
Upvotes: 1