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

时间:2018-08-06 09:57:30

标签: python python-requests

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)

这是我目前所得到的,我不断收到400个要求。我需要将数据发送为x-www-form-urlencoded 但不知道该怎么做。

0 个答案:

没有答案