Google app engine 我可以在应用程序内部创建的mechanize浏览器中打开应用程序url吗
我有一个网址如下Google app engine 我可以在应用程序内部创建的mechanize浏览器中打开应用程序url吗,google-app-engine,mechanize,Google App Engine,Mechanize,我有一个网址如下 http://myappname.appspot.com/openthisurl 在my view.py中,我创建了一个gaemechanize浏览器,如下所示 def test(request): ###1. CREATE BROWSER br = gaemechanize.Browser() # set cookies cookies = cookielib.LWPCookieJar() br.set_cookiejar(cookies)
http://myappname.appspot.com/openthisurl
在my view.py中,我创建了一个gaemechanize浏览器,如下所示
def test(request):
###1. CREATE BROWSER
br = gaemechanize.Browser()
# set cookies
cookies = cookielib.LWPCookieJar()
br.set_cookiejar(cookies)
# browser settings (used to emulate a browser)
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.set_debug_http(False)
br.set_debug_responses(False)
br.set_debug_redirects(False)
br.set_handle_refresh(gaemechanize.HTTPRefreshProcessor(), max_time=1)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
###Open http://myappname.appspot.com/openthisurl inside br
br.open('http://myappname.appspot.com/openthisurl')
#Do something
br.select_form(nr=0) # select the form
return Response('Ok')
这就是我得到的错误
内部服务器错误
回溯最近一次呼叫上次:
文件/base/data/home/apps/s~myappname/4.376620314915414228/kay/app.py,第371行,在get_响应中
响应=查看请求,**值
文件/base/data/home/apps/s~myappname/4.376620314915414228/myapp/views.py,第3669行,测试中
开放式
文件/base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize//u mechanize.py,第209行,打开
返回self.\u mech\u openurl,数据,超时=超时
文件/base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize//u mechanize.py,第236行,处于打开状态
response=UserAgentBase.openself、请求、数据
文件/base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize//u opener.py,第194行,打开
响应=urlopenself、req、数据
文件/base/data/home/runtimes/python27/python27\u dist/lib/python2.7/urllib2.py,第422行,打开
"开放",
文件/base/data/home/runtimes/python27/python27\u dist/lib/python2.7/urlib2.py,第382行,在调用链中
结果=函数*参数
文件/base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize//\u googleappengine.py,第731行,在http\u open中
返回self.do_openhttplib.HTTPConnection,req
文件/base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize//\u googleappengine.py,第708行,打开
提高URLERRERR
URLError:可能需要一些摆弄:不,我想这不是我的问题。我将br.open更改为br.open,错误消失了。似乎我无法在某个应用程序中创建浏览器,然后访问该应用程序的url。