I tried to run the code below with Python 2.7.10 Shell:
# encoding: utf8
import urllib2
import re
response=urllib2.urlopen("https://www.baidu.com/")
print response.read()
Unfortunately, I got the error:
Traceback (most recent call last):
File "C:\Users\Vivid\Desktop\LISA\datacrawling\ex.py", line 6, in <module>
response=urllib2.urlopen("https://www.baidu.com/")
File "D:\Program Files\Python2710\lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "D:\Program Files\Python2710\lib\urllib2.py", line 431, in open
response = self._open(req, data)
File "D:\Program Files\Python2710\lib\urllib2.py", line 449, in _open
'_open', req)
File "D:\Program Files\Python2710\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "D:\Program Files\Python2710\lib\urllib2.py", line 1240, in https_open
context=self._context)
File "D:\Program Files\Python2710\lib\urllib2.py", line 1197, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 11004] getaddrinfo failed>
Do you have any ideas about the problem? I've been caught by it for a long time...Thank you!