Python请求登录无法按预期工作

时间:2018-06-08 19:54:25

标签: python request

所以我不确定原因,但是在这里阅读了很多其他类似问题并解决了问题,我无法理解为什么我的请求不会在登录表单后面打印页面。我正在使用一个简单的网页来测试它,我在哪里注册。在我的有效负载中提供信用卡并使用.Session()持有cookie应该会打开我的第二个URL。但相反,我打印了登录表单。我查看了wireshark和Burp Suite,当我运行脚本时,一切看起来都很正常,看起来如果我登录到网页。

以下是代码:

# -*- coding: utf-8 -*-
import requests

url = 'http://www.chicago-cz.com/forum/login.php'

headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36'}

payload = {
    "username": "User_321", 
    "password": "S33cr3t",
}

with requests.Session() as s:
    p = s.post(url, headers=headers, data=payload)
    #print p.text

    # URL behind login (Inbox)
    r = s.get('http://www.chicago-cz.com/forum/privmsg.php?folder=inbox')
    print r.content

0 个答案:

没有答案
相关问题