urllib.urlopen: Errno socket error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kgrafals@gmail.com

    #1

    urllib.urlopen: Errno socket error

    Hi,

    I'm just trying to read from a webpage with urllib but I'm getting
    IOErrors. This is my code:

    import urllib
    sock = urllib.urlopen( "http://www.google.com/")

    and this is the error:

    Traceback (most recent call last):
    File "<pyshell#5 >", line 1, in <module>
    sock = urllib.urlopen( "http://www.google.com/")
    File "C:\Python25\li b\urllib.py", line 82, in urlopen
    return opener.open(url )
    File "C:\Python25\li b\urllib.py", line 190, in open
    return getattr(self, name)(url)
    File "C:\Python25\li b\urllib.py", line 325, in open_http
    h.endheaders()
    File "C:\Python25\li b\httplib.py", line 856, in endheaders
    self._send_outp ut()
    File "C:\Python25\li b\httplib.py", line 728, in _send_output
    self.send(msg)
    File "C:\Python25\li b\httplib.py", line 695, in send
    self.connect()
    File "C:\Python25\li b\httplib.py", line 679, in connect
    raise socket.error, msg
    IOError: [Errno socket error] (10060, 'Operation timed out')

    I'm behind my company's firewall. Would that cause a problem? If it
    does, How do I get around it?

  • Salvatore

    #2
    Re: urllib.urlopen: Errno socket error

    Hello,

    Try to increase the time out : socket.settimeo ut(n)
    and catch the timeout error when it occurs

    Regards



    kgrafals@gmail. com a écrit :
    Hi,
    >
    I'm just trying to read from a webpage with urllib but I'm getting
    IOErrors. This is my code:
    >
    import urllib
    sock = urllib.urlopen( "http://www.google.com/")
    >
    and this is the error:
    >
    Traceback (most recent call last):
    File "<pyshell#5 >", line 1, in <module>
    sock = urllib.urlopen( "http://www.google.com/")
    File "C:\Python25\li b\urllib.py", line 82, in urlopen
    return opener.open(url )
    File "C:\Python25\li b\urllib.py", line 190, in open
    return getattr(self, name)(url)
    File "C:\Python25\li b\urllib.py", line 325, in open_http
    h.endheaders()
    File "C:\Python25\li b\httplib.py", line 856, in endheaders
    self._send_outp ut()
    File "C:\Python25\li b\httplib.py", line 728, in _send_output
    self.send(msg)
    File "C:\Python25\li b\httplib.py", line 695, in send
    self.connect()
    File "C:\Python25\li b\httplib.py", line 679, in connect
    raise socket.error, msg
    IOError: [Errno socket error] (10060, 'Operation timed out')
    >
    I'm behind my company's firewall. Would that cause a problem? If it
    does, How do I get around it?

    Comment

    • kgrafals@gmail.com

      #3
      Re: urllib.urlopen: Errno socket error

      Hi Salvatore,

      Even if I catch the exceptions in a loop it goes on forever.

      - ken

      Comment

      • kgrafals@gmail.com

        #4
        Re: urllib.urlopen: Errno socket error

        Dennis,

        I tried a ProxyHandler with the following code ...

        proxy_support = urllib2.ProxyHa ndler({})
        opener = urllib2.build_o pener(proxy_sup port)
        urllib2.install _opener(opener)

        .... but it's giving me the same result.

        Then I tried to tunnel using code from ...



        .... but it too gave me an error ...

        Traceback (most recent call last):
        File "<pyshell#7 >", line 1, in <module>
        tunnel.run(tunn el_this)
        File "C:/Python25/My Python/PyTunnel.py", line 124, in run
        Threads.append( thread_it(tid=0 ,proxy=self.get _proxy(),\
        File "C:/Python25/My Python/PyTunnel.py", line 81, in get_proxy
        proxy.connect(( self._phost,sel f._pport))
        File "<string>", line 1, in connect
        gaierror: (11001, 'getaddrinfo failed')

        Comment

        • frifri007

          #5
          Re: urllib.urlopen: Errno socket error


          kgrafals@gmail. com a écrit :
          Hi,
          >
          I'm just trying to read from a webpage with urllib but I'm getting
          IOErrors. This is my code:
          >
          import urllib
          sock = urllib.urlopen( "http://www.google.com/")
          >
          and this is the error:
          >
          Traceback (most recent call last):
          File "<pyshell#5 >", line 1, in <module>
          sock = urllib.urlopen( "http://www.google.com/")
          File "C:\Python25\li b\urllib.py", line 82, in urlopen
          return opener.open(url )
          File "C:\Python25\li b\urllib.py", line 190, in open
          return getattr(self, name)(url)
          File "C:\Python25\li b\urllib.py", line 325, in open_http
          h.endheaders()
          File "C:\Python25\li b\httplib.py", line 856, in endheaders
          self._send_outp ut()
          File "C:\Python25\li b\httplib.py", line 728, in _send_output
          self.send(msg)
          File "C:\Python25\li b\httplib.py", line 695, in send
          self.connect()
          File "C:\Python25\li b\httplib.py", line 679, in connect
          raise socket.error, msg
          IOError: [Errno socket error] (10060, 'Operation timed out')
          >
          I'm behind my company's firewall. Would that cause a problem? If it
          does, How do I get around it?

          See the documentation for urllib.urlopen:

          """
          In a Windows environment, if no proxy environment variables are set,
          proxy settings are obtained from the registry's Internet Settings
          section.
          """
          Remove Proxy configuration under IE and try again
          (don't use Ie anymore ;0)

          Comment

          Working...