I am new to Scrapy and im trying to crawl this website https://www.timeanddate.com/weather/india and its throwing DNS lookup error. The code i wrote for scraping works perfectly in shell so my guess is DNS error happens before scraping takes place.
This is what i get :
2019-05-02 11:59:03 [scrapy.utils.log] INFO: Scrapy 1.6.0 started (bot: IndiaWeather)
2019-05-02 11:59:03 [scrapy.utils.log] INFO: Versions: lxml 4.3.2.0, libxml2 2.9.9, cssselect 1.0.3, parsel 1.5.1, w3lib 1.20.0, Twisted 19.2.0, Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)], pyOpenSSL 19.0.0 (OpenSSL 1.1.1b 26 Feb 2019), cryptography 2.6.1, Platform Windows-10-10.0.17134-SP0
2019-05-02 11:59:03 [scrapy.crawler] INFO: Overridden settings: {'BOT_NAME': 'IndiaWeather', 'NEWSPIDER_MODULE': 'IndiaWeather.spiders', 'SPIDER_MODULES': ['IndiaWeather.spiders']}
2019-05-02 11:59:03 [scrapy.extensions.telnet] INFO: Telnet Password: 688b4fe759cb3ed5
2019-05-02 11:59:03 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
'scrapy.extensions.telnet.TelnetConsole',
'scrapy.extensions.logstats.LogStats']
2019-05-02 11:59:03 [scrapy.middleware] INFO: Enabled downloader middlewares:
['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']
2019-05-02 11:59:03 [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']
2019-05-02 11:59:03 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2019-05-02 11:59:03 [scrapy.core.engine] INFO: Spider opened
2019-05-02 11:59:03 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2019-05-02 11:59:03 [py.warnings] WARNING: C:\Users\Abrar\Anaconda3\lib\site-packages\scrapy\spidermiddlewares\offsite.py:61: URLWarning: allowed_domains accepts only domains, not URLs. Ignoring URL entry https://www.timeanddate.com/weather/india in allowed_domains.
warnings.warn(message, URLWarning)
2019-05-02 11:59:03 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2019-05-02 11:59:05 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET http://https//www.timeanddate.com/weather/india/> (failed 1 times): DNS lookup failed: no results for hostname lookup: https.
2019-05-02 11:59:08 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET http://https//www.timeanddate.com/weather/india/> (failed 2 times): DNS lookup failed: no results for hostname lookup: https.
2019-05-02 11:59:10 [scrapy.downloadermiddlewares.retry] DEBUG: Gave up retrying <GET http://https//www.timeanddate.com/weather/india/> (failed 3 times): DNS lookup failed: no results for hostname lookup: https.
2019-05-02 11:59:10 [scrapy.core.scraper] ERROR: Error downloading <GET http://https//www.timeanddate.com/weather/india/>
Traceback (most recent call last):
File "C:\Users\Abrar\Anaconda3\lib\site-packages\twisted\internet\defer.py", line 1416, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "C:\Users\Abrar\Anaconda3\lib\site-packages\twisted\python\failure.py", line 512, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "C:\Users\Abrar\Anaconda3\lib\site-packages\scrapy\core\downloader\middleware.py", line 43, in process_request
defer.returnValue((yield download_func(request=request,spider=spider)))
File "C:\Users\Abrar\Anaconda3\lib\site-packages\twisted\internet\defer.py", line 654, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "C:\Users\Abrar\Anaconda3\lib\site-packages\twisted\internet\endpoints.py", line 975, in startConnectionAttempts
"no results for hostname lookup: {}".format(self._hostStr)
twisted.internet.error.DNSLookupError: DNS lookup failed: no results for hostname lookup: https.
2019-05-02 11:59:10 [scrapy.core.engine] INFO: Closing spider (finished)
2019-05-02 11:59:10 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/exception_count': 3,
'downloader/exception_type_count/twisted.internet.error.DNSLookupError': 3,
'downloader/request_bytes': 717,
'downloader/request_count': 3,
'downloader/request_method_count/GET': 3,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2019, 5, 2, 6, 29, 10, 505262),
'log_count/DEBUG': 3,
'log_count/ERROR': 1,
'log_count/INFO': 9,
'log_count/WARNING': 1,
'retry/count': 2,
'retry/max_reached': 1,
'retry/reason_count/twisted.internet.error.DNSLookupError': 2,
'scheduler/dequeued': 3,
'scheduler/dequeued/memory': 3,
'scheduler/enqueued': 3,
'scheduler/enqueued/memory': 3,
'start_time': datetime.datetime(2019, 5, 2, 6, 29, 3, 412894)}
2019-05-02 11:59:10 [scrapy.core.engine] INFO: Spider closed (finished)
I have posted the everything above.
Look at this error message you get:
2019-05-02 11:59:10 [scrapy.core.scraper] ERROR: Error downloading <GET http://https//www.timeanddate.com/weather/india/>
You have doubled the schema in URL (both http
and https
) and it's also invalid (no :
after the second https
). The first usually happend if you use scrapy genspider
command-line command and specify the domain already with schema.
So, remove one of the schemas from the start_urls
URLs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With