相关疑难解决方法(0)

使用python登录网站

我正在尝试使用Python 登录此页面.

我尝试使用此其他Stack Overflow帖子中描述的步骤,并获得以下代码:

import urllib, urllib2, cookielib

username = 'username'
password = 'password'

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
login_data = urllib.urlencode({'username' : username, 'j_password' : password})
opener.open('http://friends.cisv.org/index.cfm', login_data)
resp = opener.open('http://friends.cisv.org/index.cfm?fuseaction=activities.list')
print resp.read()
Run Code Online (Sandbox Code Playgroud)

但这给了我以下输出:

<SCRIPT LANGUAGE="JavaScript">
    alert('Sorry.  You need to log back in to continue. You will be returned to the home page when you click on OK.');
    document.location.href='index.cfm';
</SCRIPT>
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

python cookies login

17
推荐指数
1
解决办法
5万
查看次数

标签 统计

cookies ×1

login ×1

python ×1