urllib.error.URLError:

后端 未结 2 1781
难免孤独
难免孤独 2020-12-21 09:58

So, My code is only 4 lines. I am trying to connect to a website, what I am trying to do after that is irrelevant because the error arised without the other codes.

相关标签:
2条回答
  • 2020-12-21 10:39

    This is an issue with DNS; apparently your python program cannot resolve the hostname of the URL you provide. Maybe DNS is badly configured on the host it is running on?

    Additionally, may I recommend using the requests library? This is a much nicer and easier to use module to do web requests. You'll find it here: https://pypi.python.org/pypi/requests

    0 讨论(0)
  • 2020-12-21 10:47

    This means that either your DNS system is not working correctly, or you have to use a proxy on your network and it isn't defined correctly.

    If you need to use a proxy, set the environment variable HTTP_PROXY (and optionally, HTTPS_PROXY) to the correct configuration for your network. The format is http://proxy.example.com:80; if your proxy needs a username and password, you should pass it in, like this: http://username:password@proxy.example.com:80.

    For DNS issues, try looking up the domain from the command line. Open a command prompt and type nslookup python-data.dr-chuck.net and see if it returns to you an IP address.

    0 讨论(0)
提交回复
热议问题