[问题] 该怎么用python登入自己写的表单?

楼主: phpjson (json_encode)   2016-04-12 23:54:55
大家好
新手在下 写了一个测试网页 位在 http://pure.comxa.com/index.html
帐号是 test@test.com 密码是 test
登入成功 会显示 you did it 登入失败 会跳js窗 说error
现在 想用python 3 练习登入
然而 每次都会传回登入错误的页面 不知道错在哪
实在是很困惑
不知是否有高手能救救我呢???? >< 谢谢各位
程式码如下
import requests
import urllib
from requests import session
headers = {'User-Agent': 'Mozilla/5.0'}
payload = {
'action': 'loginSuccessDisplay.php',
'userName':'test@test.com',
'pswd':'test'
}
with session() as c:
c.post('http://pure.comxa.com/index.html',headers=headers,data=payload)
response = c.get('http://pure.comxa.com/loginSuccessDisplay.php')
# 改成index.html还是不行 会返回登入页面@@
print(response.headers)
print(response.text)
话说我的网页后台并不会产生session
而是只是单纯的验证username pswd有没有match
请问这是问题症结点吗?
还是我的 request 写错了呢? >< 恳请大大赐教谢谢
楼主: phpjson (json_encode)   2016-04-13 01:22:00
oh! 我知道了 我把with session() as c给删了然后就好了 是因为后台没有session的关系???但是也有点好奇, 自动跳转的网页 get back 的url 该填啥请问有前辈大大能解惑吗??? 感恩....

Links booklink

Contact Us: admin [ a t ] ucptt.com