Browser Backend and Grab examples errors
ANTARESXXI opened this issue · 2 comments
For Browser Backend example:
Traceback (most recent call last):
File ".../main.py", line 35, in
print(solver.solve_captcha(raw_data))
File "C:\Python27\lib\site-packages\captcha_solver\solver.py", line 58, in solve_captcha
captcha_id = self.submit_captcha(image_data=data, *_kwargs)
File "C:\Python27\lib\site-packages\captcha_solver\solver.py", line 38, in submit_captcha
response = self.network_backend.request(data['url'], data['post_data'])
File "C:\Python27\lib\site-packages\captcha_solver\transport_backend\urllib_backend.py", line 13, in request
response = urlopen(request)
File "C:\Python27\Lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python27\Lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Python27\Lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Python27\Lib\urllib2.py", line 409, in _call_chain
result = func(_args)
File "C:\Python27\Lib\urllib2.py", line 1335, in file_open
return self.open_local_file(req)
File "C:\Python27\Lib\urllib2.py", line 1375, in open_local_file
raise URLError(msg)
urllib2.URLError: <urlopen error [Error 3] : ''>
For Grab example:
Traceback (most recent call last):
File ".../main.py", line 27, in
print (solve_captcha(solver, g, url=url))
File "C:\Python27\lib\site-packages\captcha_solver\contrib\grab\captcha.py", line 11, in solve_captcha
solution = solver.solve_captcha(data=data, *_kwargs)
File "C:\Python27\lib\site-packages\captcha_solver\solver.py", line 58, in solve_captcha
captcha_id = self.submit_captcha(image_data=data, *_kwargs)
File "C:\Python27\lib\site-packages\captcha_solver\solver.py", line 38, in submit_captcha
response = self.network_backend.request(data['url'], data['post_data'])
File "C:\Python27\lib\site-packages\captcha_solver\transport_backend\urllib_backend.py", line 13, in request
response = urlopen(request)
File "C:\Python27\Lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python27\Lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "C:\Python27\Lib\urllib2.py", line 449, in _open
'_open', req)
File "C:\Python27\Lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Python27\Lib\urllib2.py", line 1335, in file_open
return self.open_local_file(req)
File "C:\Python27\Lib\urllib2.py", line 1375, in open_local_file
raise URLError(msg)
urllib2.URLError: <urlopen error [Error 3] : ''>
for me, it seems this is a problem with the local file format on windows.
I hacked my way to a solution in solver.py by changing submit_captcha to:
def submit_captcha(self, image_data, **kwargs):
logger.debug('Submiting captcha')
data = self.captcha_backend.get_submit_captcha_request_data(image_data,**kwargs)
url2 = "file:"+urllib.pathname2url(data['url'].replace("file://",""))
#print "fixed url:" +url2
response = self.network_backend.request(url2, data['post_data'])
return self.captcha_backend.parse_submit_captcha_response(response)
and adding
import urllib
Yeah urllib_backend.py is using python 2 libraries that don't exist in python 3. I saw those libraries used in a few other places, this really needs to be tested.