Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在x-www-form-urlencoded中发送Python Post请求_Python_Python Requests - Fatal编程技术网

如何在x-www-form-urlencoded中发送Python Post请求

如何在x-www-form-urlencoded中发送Python Post请求,python,python-requests,Python,Python Requests,这是我目前得到的,我一直收到400个请求。我需要以x-www-form-urlencoded的形式发送数据 但是我不知道怎么做。你从哪里得到400,是按get请求还是post请求?post请求。 loginurl = 'https://www.net-a-porter.com/gb/en/signin.nap' j_username = 'danny@dannytaylor.club' j_password = 'Password1' data = { '

这是我目前得到的,我一直收到400个请求。我需要以x-www-form-urlencoded的形式发送数据
但是我不知道怎么做。

你从哪里得到400,是按get请求还是post请求?post请求。
loginurl = 'https://www.net-a-porter.com/gb/en/signin.nap'
    j_username = 'danny@dannytaylor.club'
    j_password = 'Password1'
    data = {
        'j_username': 'danny@dannytaylor.club',
        'j_password': 'Password1'
}
headers = {'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36', "Referer" : "https://www.net-a-porter.com/"}
    s.get(loginurl, headers=headers)
    login_data = dict(j_username=j_username,j_password=j_password,)
    #z = s.post(loginurl, data=login_data, headers=headerPost, allow_redirects=False)
    z = s.post(loginurl, data=data, headers=headers)
    print(z.text)
    s.get('https://www.net-a-porter.com/en-gb/account', headers=headers)
    print(z.status_code)
    time.sleep(2)