python如何在GAE重定向中包含参数?

2024-04-19 13:20:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我可以使用下面的代码在GAE上使用gaemechanize登录到第三方网站:

import webapp2
import _mechanize

class MainPage(webapp2.RequestHandler):
  def get(self):
    br = _mechanize.Browser()
    res = br.open('http://www.example.com/login')


    br.select_form(name = 'form1')
    br['AccountName'] = 'username'
    br['Password'] = 'password'
    response = br.submit()
    #at this point the login is successful:
    #how would one then redirect the user to the example site as a logged in user?


app = webapp2.WSGIApplication([('/', MainPage)], debug=True)

问题是:在使用mechanize登录之后,应用程序如何将用户的浏览器重定向到作为已登录用户的示例站点?换句话说,有没有办法将登录状态从mechanize“转移”到用户的浏览器?你知道吗

一种方法是使用mechanize的会话信息重定向浏览器,但是GAE自我重定向看起来它只接受没有任何参数的URL。你知道吗


Tags: the代码用户brimportexample浏览器login