httplib(set_tunnel、サポートされていないようです: http ://code.google.com/p/googleappengine/source/browse/trunk/python/)を使用して、GoogleAppEngineのプロキシ経由でHTTPPOSTリクエストを行うことができません。google / appengine / dist27 / httplib.py?r = 281&spec = svn281)またはurllib2。
事実、ローカルテストでは、リクエストが機能しているように見えるかどうか、少なくとも何かを返すかどうか、プロキシ経由か直接(urllib2のようにhttplib(set_tunnel)を使用)かはわかりませんが、変更をアップロードするとGoogleのサーバーは何も機能しません。
リクエストを行うために使用する関数は次のとおりです。
def __urllib2Post(self, post_args, tokenizer):
Post = urllib.urlencode(post_args, doseq=True)
headers = {
"User-Agent": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)",
#"Host": "servicios.mitele.es",
#"Accept-Encoding": "gzip",
"Accept-Charset": "ISO-8859-1,UTF-8;q=0.7,*;q=0.7",
"Referer": "http://static1.tele-cinco.net/comun/swf/playerMitele.swf",
"Connection": "close",
"Accept-Language": "de,en;q=0.7,en-us;q=0.3",
"Content-type": "application/x-www-form-urlencoded"
}
url = "http://servicios.mitele.es" + tokenizer
proxy_h = urllib2Local.ProxyHandler({"http" : "80.58.250.68:80"})
opener = urllib2Local.build_opener(proxy_h)
urllib2Local.install_opener(opener)
req = urllib2Local.Request(url, Post, headers)
response = urllib2Local.urlopen(req)
return response.read()
def __post(self, post_args, tokenizer):
Post = urllib.urlencode(post_args, doseq=True)
headers = {
"User-Agent": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)",
#"Host": "servicios.mitele.es",
#"Accept-Encoding": "gzip",
"Accept-Charset": "ISO-8859-1,UTF-8;q=0.7,*;q=0.7",
"Referer": "http://static1.tele-cinco.net/comun/swf/playerMitele.swf",
"Connection": "close",
"Accept-Language": "de,en;q=0.7,en-us;q=0.3",
"Content-type": "application/x-www-form-urlencoded"
}
#conn = httplib.HTTPConnection("213.4.97.107", 80)
conn = httplib.HTTPConnection("servicios.mitele.es", 80)
conn.set_tunnel("80.58.250.68", 80, headers)
conn.request("POST", tokenizer, Post, headers)
response = conn.getresponse()
#print response.status, response.reason
if response.status == 404: #NOT FOUND
data = None
elif response.status == 400: #BAD REQUEST
data = None
else:
data = response.read()
conn.close()
return data
スペインの主要テレビのウェブサイトのビデオへのダウンロードリンクを見つけるウェブサイトがあり、地理的にロックされているものもあり、スペインのプロキシを介してリクエストする必要があるため、これを行う必要があります。リクエストはPOST形式である必要があるため、Webプロキシを使用できません。
Google AppEngineのプロキシを介してHTTPPOSTリクエストを実行する方法はありますか?
どんな助けでも大歓迎です..私の英語でごめんなさい。