作者phpjson (php er)
看板Python
標題[問題] 該怎麼用python登入自己寫的表單?
時間Tue Apr 12 23:54:55 2016
大家好
新手在下 寫了一個測試網頁 位在
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 寫錯了呢? >< 懇請大大賜教謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.217.5.163
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1460476500.A.2CF.html
※ 編輯: phpjson (180.217.5.163), 04/13/2016 01:17:22
→ phpjson: oh! 我知道了 我把with session() as c給刪了 04/13 01:22
→ phpjson: 然後就好了 是因為後台沒有session的關係??? 04/13 01:23
→ phpjson: 但是也有點好奇, 自動跳轉的網頁 get back 的url 該填啥 04/13 01:27
→ phpjson: 請問有前輩大大能解惑嗎??? 感恩.... 04/13 01:28