URL을 가져오고 문서에 명시된대로 urllib2를 사용하여 일부 처리를 수행하는 GAE를 사용하는 간단한 응용 프로그램을 작성합니다.urlopen()에 대한 GAE getaddrinfo 오류
import webapp2
import urllib2
class Handler(webapp2.RequestHandler):
def get(self):
url = "http://www.google.com/"
try:
result = urllib2.urlopen(url)
self.response.out.write(result)
except urllib2.URLError, e:
handleError(e)
app = webapp2.WSGIApplication([("/", Handler)], debug = True)
urlfetch와 동일하게 시도했지만 동일한 오류가 계속 발생합니다.
IP 주소로 urlopen()을 호출하면 정상적으로 작동합니다.
DNS 문제 일 수 있다고 생각했지만 인터프리터에서 urllib2.urlopen("http://www.google.com")
(으)로 전화하면 올바르게 해석되었습니다. 또한 문제없이 찾아보고 핑할 수 있습니다.
친구에게 환경에 대한이 코드를 사용해달라고 요청했는데 그 결과는 같았습니다.
동일한 코드를 실행하는 배포 된 응용 프로그램은 정상적으로 작동합니다.
ISP에서 문제가 될 수 있는지 궁금합니다. 3 번의 시도가 모두 동일한 ISP에서 이루어 졌기 때문에 궁금합니다.
아니요. 적어도 프록시를 구성하지 않았거나 볼 수있는 프록시가 없습니다.
result = urllib2.urlopen(url).read()
당신의 DNS 리졸버의 설정을 확인하시기 바랍니다, 보안 소프트웨어, 또는 http : 여기
내가 다음과 같이 코드를 수정 한 후Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
return handler.dispatch()
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "C:\Users\Developer\Desktop\test\main.py", line 8, in get
result = urllib2.urlopen(url)
File "C:\Python27\lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 400, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 418, in _open
'_open', req)
File "C:\Python27\lib\urllib2.py", line 378, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1207, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python27\lib\urllib2.py", line 1180, in do_open
r = h.getresponse(buffering=True)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\dist27\httplib.py", line 507, in getresponse
'An error occured while connecting to the server: %s' % e)
error: An error occured while connecting to the server: Unable to fetch URL: http://www.google.com/ Error: [Errno 10106] getaddrinfo failed