다음 코드는 프록시 외부에서 프로그램을 실행할 때 실행됩니다. Windows 7 운영 체제를 사용하여 작업중인 프록시에서이 프로그램을 실행하면 명령 프롬프트에서 "[Errno 11004]"또는 Cygwin에서 "[Errno 8]"을 얻습니다.파이썬 충돌 [Errno] 메시지
이 프로그램의 목표는 경영진이 당사 소유의 웹 사이트의 HTTP 응답 및 URL 리디렉션을 캡처하는 데 사용할 수있는 휴대용 실행 파일입니다.
#!/bin/python
import urllib, urllib2, sys, logging, time
# Variables
s = time.strftime('%Y%m%d%H%M%S')
f = open("list.txt",'r')
# Logging
class Logger(object):
def __init__(self):
self.terminal = sys.stdout
self.log = open("assets_"+s+".txt", "a")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
# Capture logging class
sys.stdout = Logger()
# Text file header
print "ASSET, STATUS, REDIRECT, DATE/TIME"
# Feed program 16,000 URLs
for url in f.readlines():
try:
http_connection = 'http://' + (url)
connection = urllib2.urlopen(http_connection)
print (url).rstrip("\n"), ",", connection.getcode(), ",", connection.geturl(), ",", (s)
connection.close()
except urllib2.URLError as e:
print e.reason
합니까 [이 질문] (http://stackoverflow.com/questions/4847649/opening-websites-using-urllib2-from-behind-corporate-firewall-11004-getaddrinf) 도움이 필요하십니까? – bbayles