小编Per*_*run的帖子

Python和机械化登录脚本

嗨其他程序员!

我正在尝试编写一个脚本,使用python和mechanize模块登录我的大学"食物平衡"页面...

这是我尝试登录的页面:http://www.wcu.edu/11407.asp 该网站有以下表格登录:

<FORM method=post action=https://itapp.wcu.edu/BanAuthRedirector/Default.aspx><INPUT value=https://cf.wcu.edu/busafrs/catcard/idsearch.cfm type=hidden name=wcuirs_uri> 
<P><B>WCU ID Number<BR></B><INPUT maxLength=12 size=12 type=password name=id> </P>
<P><B>PIN<BR></B><INPUT maxLength=20 type=password name=PIN> </P>
<P></P>
<P><INPUT value="Request Access" type=submit name=submit> </P></FORM>
Run Code Online (Sandbox Code Playgroud)

据此我们知道我需要填写以下字段:1.name = id 2. name = PIN

通过操作:action = https://itapp.wcu.edu/BanAuthRedirector/Default.aspx

这是我到目前为止编写的脚本:

#!/usr/bin/python2 -W ignore

import mechanize, cookielib
from time import sleep

url   = 'http://www.wcu.edu/11407.asp'
myId  = '11111111111'
myPin = '22222222222'

# Browser
#br = mechanize.Browser()
#br = mechanize.Browser(factory=mechanize.DefaultFactory(i_want_broken_xhtml_support=True))
br = mechanize.Browser(factory=mechanize.RobustFactory()) # Use this because of bad …
Run Code Online (Sandbox Code Playgroud)

python mechanize login-script python-memcached

8
推荐指数
1
解决办法
8714
查看次数