- 2
- 이니스프리
- 조회 수 1070
안녕하세요?
파이썬 Requests를 이용하여 아래 URL에서 할인 정보를 받아오는 스크립트를 작성했습니다.
s.get(https://www.premiumoutlets.co.kr/yeoju/sales_events/in_store_promotions)
그런데 GET 요청을 하면 Temporary failure in name resolution 에러가 발생하네요.
특이한 점은 동일한 스크립트로 윈도우에서는 잘 되는데 우분투 VPS에서 에러가 발생한다는 점이네요.
그리고 항상 안 되는 것이 아니라 간혹 우분투에서도 동일한 GET 요청에 성공하는 경우도 있더군요 ㄷㄷ
구글링해보니 1. pyopenssl을 설치해라, 2. time.sleep()을 충분히 줘라 이런 조언이 있었지만 이 방식으로는 해결되지 않았습니다.
방화벽 문제일 가능성이 높아서 그런 쪽으로도 구글링해서 해결해보려고 했는데 잘 안 되더군요 ㅠㅠ
그런데 HTTP 통신에서 GET 요청은 80번 또는 443번 포트 아닌가요?? 파이썬 Requests는 HTTP 통신이 아닌가 보죠?? ㅎㄷㄷ
제 수준에서는 도저히 해결이 안 되는 문제 같아서 에러 메시지를 긁어왔습니다.
그럼 점심식사 맛있게 드시고 편안한 오후 되세요~!
항상 감사드립니다 ^-^
Traceback (most recent call last):
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/util/connection.py", line 60, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "/usr/local/anaconda/lib/python3.6/socket.py", line 743, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
conn.connect()
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/connection.py", line 284, in connect
conn = self._new_conn()
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/anaconda/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/anaconda/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.premiumoutlets.co.kr', port=443): Max retries exceeded with url: /yeoju/sales_events/in_store_promotions (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "outlet.py", line 98, in
result = parse_sh(u, urls[u])
File "outlet.py", line 28, in parse_sh
html = s.get(url)
File "/usr/local/anaconda/lib/python3.6/site-packages/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/usr/local/anaconda/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/anaconda/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/anaconda/lib/python3.6/site-packages/requests/adapters.py", line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.premiumoutlets.co.kr', port=443): Max retries exceeded with url: /yeoju/sales_events/in_store_promotions (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
우분투 VPS에서 DNS 서버를 구글 DNS 서버나 CloudFlare DNS 서버로 설정해보시겠어요?