gpt4 book ai didi

python Mechanize session 未保存

转载 作者:行者123 更新时间:2023-12-04 16:19:33 25 4
gpt4 key购买 nike

我正在尝试使用 python mechanize 来检索 iTunes 连接上的应用程序列表。检索到此列表后,将对这些链接进行进一步的工作。

登录成功,但是当我点击“管理您的应用程序”链接时,我被重定向回登录页面。就好像 session 丢失了一样。

import mechanize
import cookielib
from BeautifulSoup import BeautifulSoup
import html2text

filename = 'itunes.html'

br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)

br.set_handle_refresh(mechanize._http.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')]

br.open('https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa')
br.select_form(name='appleConnectForm')
br.form['theAccountName'] = username
br.form['theAccountPW'] = password

br.submit()

apps_link = br.find_link(text='Manage Your Applications')
print "Manage Your Apps link = ", apps_link
req = br.follow_link(text='Manage Your Applications')

for app_link in br.links():
print "link is ", app_link

任何想法可能是错误的?

最佳答案

您需要save/load cookies jar

关于python Mechanize session 未保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9778870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com