我需要用python请求一些网址。我使用标准的urllib2 procdeure,例如:
urllib2.urlopen('http://google.com')
没问题。但是,当使用以破折号开头的URL时,例如:
urllib2.urlopen('http://-cityoflove.tumblr.com/')
脚本代码错误:
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
有没有人可以通过python获取域名?
如果可以提供帮助,请注意 wget 发生同样的错误:
wget http://-cityoflove.tumblr.com/
崩溃时出错:
wget: unable to resolve host address `-cityoflove.tumblr.com'
请注意,此错误会在ubuntu错误上通知:https://bugs.launchpad.net/ubuntu/+source/resolvconf/+bug/668926