我有一个类似下面的网址
http://myappname.appspot.com/openthisurl
在我的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_response中 response = view_func(request,** values)
文件" /base/data/home/apps/s~myappname/4.376620314915414228/myapp/views.py",第3669行,在测试中 br.open(' http://myappname.appspot.com/openthisurl&#39)
文件" /base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize/_mechanize.py" ;,第209行,公开 return self._mech_open(url,data,timeout = timeout)
文件" /base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize/_mechanize.py" ;,第236行,在_mech_open response = UserAgentBase.open(self,request,data)
文件" /base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize/_opener.py" ;,第194行,公开 response = urlopen(self,req,data)
文件" /base/data/home/runtimes/python27/python27_dist/lib/python2.7/urllib2.py" ;,第422行,在_open中 ' _open',req)
文件" /base/data/home/runtimes/python27/python27_dist/lib/python2.7/urllib2.py",第382行,在_call_chain中 result = func(* args)
文件" /base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize/_googleappengine.py",第731行,http_open return self.do_open(httplib.HTTPConnection,req)
文件" /base/data/home/apps/s~myappname/4.376620314915414228/myapp/gaemechanize/_googleappengine.py",第708行,在do_open中 提出URLError(错误)
URLError: