本文介绍了python代理嵌入一个iframe中的谷歌应用脚​​本服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个python代理以使用IFrame。我怀疑代理需要替换SAMEORIGIN标签并使用ajax样式的POST命令。
这对我来说是新的领域,以前从未需要设置代理。



Google Apps脚本示例页面:



此代理解决方案看起来很接近:



我找到了设置代理的说明在App Engine上,但是这会失败,并带有ajax样式的POST命令:



这是已知的Google Apps Script#546和#522。大约1岁,大约有100人在寻找解决方案。 bs2grproxy只需要进行一些小改动。
我在这里发布了解决方案:



更改:

在第48行的文件bs2grproxy.py中,raise Exception('Unsupported ...insert:

  scm ='https'

如果获取了:
,如果是resp,则返回

 headers.get('Content-Type','').find('html')> = 0:
resp.content = resp.content +'< style type =text / css> .warning-panel {display:none;}< / style>'
resp.headers ['x-frame-options'] ='IGNORE'
logging.info(warning-panel hidden and x-frame-options reset)

您可能还需要在bs2grproxy.py中更改代理超时时间,如下所示:

  resp = urlfetch.fetch(new_path,self.request。 body,method,newHeaders,False,False,30)

Eddy。

How can I create a python proxy to work from an IFrame. I suspect the proxy needs to replace the SAMEORIGIN tag and work with ajax style POST commands. This is new ground for me, never needed to setup a proxy before.

Example Google Apps Script page: https://docs.google.com/macros/exec?service=AKfycbyrbgVS39Hf-RHYVPbnCKzf_uVaD0sGeFSKEqyRIw

This proxy solutions looks close: How do I get my simple twisted proxy to work?

I found instructions for setting up a proxy on App Engine, but this fails with ajax style POST commands:http://www.labnol.org/internet/setup-proxy-server/12890/

This is a known Google Apps Script issue #546 and #522. About 1 year old with about 100 people looking for a solution.

解决方案

The bs2grproxy works with a few small changes.I posted the solution here: http://code.google.com/p/google-apps-script-issues/issues/detail?id=546#c104

The changes:

In file bs2grproxy.py below line 48, "raise Exception('Unsupported ..." insert:

        scm = 'https'

below line 134, "raise Exception('Requested ..." insert:

            if fetched:
                if resp.headers.get('Content-Type', '').find('html') >= 0:
                    resp.content = resp.content + '<style type="text/css"> .warning-panel {display: none;} </style>'
                    resp.headers['x-frame-options'] = 'IGNORE'
                    logging.info("warning-panel hidden and x-frame-options reset")

You may also need to change the proxy time out in bs2grproxy.py, like this:

resp = urlfetch.fetch(new_path, self.request.body, method, newHeaders, False, False, 30)

Eddy.

这篇关于python代理嵌入一个iframe中的谷歌应用脚​​本服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 06:06