302s and losing cookies with urllib2

后端 未结 4 1881
旧时难觅i
旧时难觅i 2021-01-21 06:13

I am using liburl2 with CookieJar / HTTPCookieProcessor in an attempt to simulate a login to a page to automate an upload.

I\'ve seen some questions and answers on this,

4条回答
  •  执笔经年
    2021-01-21 07:01

    Depends on how the redirect is done. If it's done via a HTTP Refresh, then mechanize has a HTTPRefreshProcessor you can use. Try to create an opener like this:

    cj = mechanize.CookieJar()
    opener = mechanize.build_opener(
        mechanize.HTTPCookieProcessor(cj),
        mechanize.HTTPRefererProcessor,
        mechanize.HTTPEquivProcessor,
        mechanize.HTTPRefreshProcessor)
    

提交回复
热议问题