0

我正在尝试使用抓取(版本 0.4.8)连接“ https://myvodafone.vodafone.in/myvodafoneselfcare/jsp/commons/login.jsp ”。我收到以下错误。

ERROR:in_vodafone:17162:375: (<class 'grab.error.GrabNetworkError'>, GrabNetworkError(35, 'error:140773E8:SSL routines:SSL23_GET_SERVER_HELLO:reason(1000)'), <traceback object at 0x10277cb00>)
DEBUG:in_vodafone:17162:Traceback (most recent call last):
  File "in_vodafone.py", line 308, in download
    g.go('http://www.vodafone.in/pages/myvodafone.aspx')
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/grab-0.4.7-py2.7.egg/grab/base.py", line 306, in go
    return self.request(url=url, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/grab-0.4.7-py2.7.egg/grab/base.py", line 384, in request
    self.transport.request()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/grab-0.4.7-py2.7.egg/grab/transport/curl.py", line 345, in request
    raise error.GrabNetworkError(ex[0], ex[1])
GrabNetworkError: [Errno 35] error:140773E8:SSL routines:SSL23_GET_SERVER_HELLO:reason(1000)

我的脚本包含以下代码:

from grab import Grab
g = Grab()
g.setup(hammer_mode = True, hammer_timeouts = ((100, 200), (300, 400), (500, 600)))
g.go('https://myvodafone.vodafone.in/myvodafoneselfcare/jsp/commons/login.jsp')

我发现在http://bugs.python.org/issue11220中有一个 urllib 的解决方案来解决这个问题。如何将此解决方案与抓取实用程序一起使用?

4

1 回答 1

0

我找到了以下解决方案,并且效果很好。

from grab import Grab
import pycurl

g = Grab()
g.transport.curl.setopt(pycurl.SSLVERSION, 3)
g.setup(hammer_mode = True, hammer_timeouts = ((100, 200), (300, 400), (500, 600)))
g.go('https://myvodafone.vodafone.in/myvodafoneselfcare/jsp/commons/login.jsp')
于 2013-02-25T08:24:59.073 回答