作者phpjson (php er)
看板Python
标题[问题] 该怎麽用python登入自己写的表单?
时间Tue Apr 12 23:54:55 2016
大家好
新手在下 写了一个测试网页 位在
http://pure.comxa.com/index.html
帐号是
[email protected] 密码是 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':'
[email protected]',
'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 写错了呢? >< 恳请大大赐教谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 180.217.5.163
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1460476500.A.2CF.html
※ 编辑: phpjson (180.217.5.163), 04/13/2016 01:17:22
1F:→ phpjson: oh! 我知道了 我把with session() as c给删了 04/13 01:22
2F:→ phpjson: 然後就好了 是因为後台没有session的关系??? 04/13 01:23
3F:→ phpjson: 但是也有点好奇, 自动跳转的网页 get back 的url 该填啥 04/13 01:27
4F:→ phpjson: 请问有前辈大大能解惑吗??? 感恩.... 04/13 01:28