I am writing a spider for a public FTP site with authentication
I gave the username and password for ftp. Scrapy does not process this request and gives ftp_user error
class my_xml(BaseSpider):
name = 'my_xml'
def start_requests(self):
yield Request(
url='url',
meta={'ftp_user': self.ftp_user, 'ftp_password': self.ftp_password}
)
def parse(self, response):
print response.body
I get an error like this.
2015-04-03 12:46:08+0530 [scrapy] DEBUG: Telnet console listening on 127.0.0.1:6023
2015-04-03 12:46:08+0530 [scrapy] DEBUG: Web service listening on 127.0.0.1:6080
2015-04-03 12:46:08+0530 [-] ERROR: Unhandled error in Deferred:
2015-04-03 12:46:08+0530 [-] Unhandled Error
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\scrapy\core\downloader\middleware.py", line 38, in process_request
return download_func(request=request, spider=spider)
File "C:\Python27\lib\site-packages\scrapy\core\downloader\__init__.py", line 123, in _enqueue_request
self._process_queue(spider, slot)
File "C:\Python27\lib\site-packages\scrapy\core\downloader\__init__.py", line 143, in _process_queue
dfd = self._download(slot, request, spider)
File "C:\Python27\lib\site-packages\scrapy\core\downloader\__init__.py", line 154, in _download
dfd = mustbe_deferred(self.handlers.download_request, request, spider)
File "C:\Python27\lib\site-packages\scrapy\utils\defer.py", line 39, in mustbe_deferred
result = f(*args, **kw)
File "C:\Python27\lib\site-packages\scrapy\core\downloader\handlers\__init__.py", line 40, in download_request
return handler(request, spider)
File "C:\Python27\lib\site-packages\scrapy\core\downloader\handlers\ftp.py", line 72, in download_request
creator = ClientCreator(reactor, FTPClient, request.meta["ftp_user"],
exceptions.KeyError: 'ftp_user'
Anyone can give a solution to this error.? If I am doing the wrong procedure, offer me the right solution. How to handle these types of spiders? Please note that: URL, ftp_user and ftp_password are correct, and in the browser we can open it with this data.