gpt4 book ai didi

python 身份验证

转载 作者:太空宇宙 更新时间:2023-11-04 01:40:42 26 4
gpt4 key购买 nike

我是 python 的新手,经过一番努力后,我几乎可以使用代码了。

import urllib, urllib2, cookielib

username = 'myuser'
password = 'mypass'

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login = urllib.urlencode({'user' : username, 'pass' : password})
opener.open('http://www.ok.com/', login)
mailb = opener.open('http://www.ok.com/mailbox').read()
print mailb

但是我打印后得到的输出只是一个重定向页面。

<html>

<head>

<META HTTP-EQUIV="Refresh" CONTENT="0;URL=https://login.ok.com/login.html?skin=login-page&dest=REDIR|http://www.ok.com/mailbox">

<HTML dir=ltr><HEAD><TITLE>OK :: Redirecting</TITLE>

</head>

</html>

谢谢

最佳答案

如果浏览器收到该响应,它会将其解释为重定向到指定 URL 的请求。

您需要对脚本执行类似的操作。您需要解析 <META>标记并找到 URL,然后对该 URL 执行 GET。

关于 python 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5172233/

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