cy07483 发表于 2024-7-29 13:44

curl命令转成python运行就出错是怎么回事


这段代码curl命令转换来的,curl运行正常,转换成python就运行错误了,求解
import requests

headers = {
    'Host': 'm.flight.qunar.com',
    'Content-Type': 'application/json; charset=UTF-8',
    'Origin': 'https://m.flight.qunar.com',
    'Accept-Encoding': 'gzip, deflate, br',
    'Cookie': 'QN270=8D781184-CC68-49AD-AE8E-CC14485E0C3E%2C80011327%2CC1001%2C8BACD822-8FC4-AEE9-94CA-C5E443A1AE67%2C10010%2C8D781184-CC68-49AD-AE8E-CC14485E0C3E%2C06B7442B-4F74-4FFB-A33A-4FD0C9137E6B; _q=U.thhwomm3976; _s=s_P33MGUMGH6C7PXSXV4FBD73ORM; _t=29184643; _v=wW_R9E1ZiPdxlRm5qLVWKnZVh7Bm7a3Ppa5CTCYQf2hr_LwKwQ5k8b41PHIDoWRgYbwGZwh3cq_lbITkhoO7wGekd2T4ijzD1J5zKVH3bUlyG2BW9pgSL84QjVDXBH7Zh98K0jTpFUuU9uwOb_EZvOh6v3OYouhxq5cggFeHmu-g; csrfToken=S4qtqWSJnjaYuc7; QN300=zn_summertask; cs_june=49a88f0dfa80248233f19bacf17fd1314d82f628a26c2bf469e77f9f74eda4482b03a3a09af637589c2fdeca103f398b87fad237f626b11f6f89ed85156d4cbeb17c80df7eee7c02a9c1a6a5b97c117927932a7f9e1526e317e0c2b675b866915a737ae180251ef5be23400b098dd8ca; ctf_june=1683616182042##iK3wVRDsVhPwawPwa%3DGTXPWIWRDsW%3DDAXsjsW%3DjsVDXsVKD8W2X%2BVPD%3DVPfRiK3siK3saKgwaS3saKv%2BaRgAVuPwaUvt; q_ckey=dT10aGh3b21tMzk3NiZrPUU0MjAyMDY4M0ZDQkUyMTVDQUYyQ0E0NUJBNTc0ODEzJnQ9MTcyMjIzMTAzNzk0MCZkPWVqYWJob3N0Mg==; QN233=; ctt_june=1683616182042##iK3waSPnVhPwawPwasERasEDaDPmXS2%2BVRHIaRkhaDD8aDiRVR3OaKgwEStwiK3siK3saKgwaKDmWRDNWstwawPwaUvt; QN48=tc_b105c19c397196c0_190be925640_d2a7; QN1=0000ef004138626dad9075fc',
    'Connection': 'keep-alive',
    'Accept': '*/*',
    'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 QunariPhone/80011327 m/9.2',
    'Referer': 'https://m.flight.qunar.com/shark/active/641e210d9448f9fb974f8fdf33cf94be',
    'Content-Length': '2688',
    'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
}

data = '{"userIp":"","clientGps":"37.37479782371633,122.16617583709194","wifi_bssid":"6c:99:89:b1:73:1c","wifiBssid":"6c:99:89:b1:73:1c","wifi_ssid":"wifi","wifiSsid":"wifi","appInfo":"{"fp":"dF2VbD9dFnFlPH39pHl01zjP5JlEx7fgMSam9p+SB2b+zRjGXzGPo4rJvYKP47gnQQHesGMoMHUPeibwZ0ERjEt3VtZqDz6CEA+2H8t/xx5r3ut3oxAPNlKPHudRdK5IeZpNWtEFbekq9J5ODb+Ga112fK9BA2wKnSk2CzPCLBgS8fgoPuQAUTohvuFM3RFpEheDZtXEf9KLUE5gTNh+OAbO+NkU5NlUxc8e4DnYY4r20m09SrZ/1ZJ02Bs0P8ljQ+mM/dsHTMBzdR1IKnZ82p+YDl0l9RT6C6a23v9bVvOqv5OpLXnykXr38NbgHK/XXO5548gaOlUCf0T+9T7K/1QiswChF4G7utiY65/yBQPMgiHJBlbD7vkyi5uG4uk9y9qbgBTYJPwFWvxRoUH1ow==","uuid":"s_P33MGUMGH6C7PXSXV4FBD73ORM","lt":1,"uid":"8D781184-CC68-49AD-AE8E-CC14485E0C3E","releaseType":"release","hyVersionName":"3.20.0","vid":"80011327","cid":"C1001","patchVersion":"0","usid":"1524232512","gid":"8BACD822-8FC4-AEE9-94CA-C5E443A1AE67","sid":"89D7EF08-D7FA-0F9E-7A23-CDF0195926B6","pid":"10010","hyVersion":"329","aid":"7CFE2AD4-91CF-49E3-B41D-478A42010462","versioninfo":""}","ua":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 QunariPhone/80011327 m/9.2","platform":"ios","osVersion":"15.7.2","modal":"iPhone9,2","network":"wifi","userIpNetworkType":"wifi","channel":"APP","userInfo":{"uid":"8D781184-CC68-49AD-AE8E-CC14485E0C3E","gid":"8BACD822-8FC4-AEE9-94CA-C5E443A1AE67","vid":"80011327","pid":"10010","cid":"C1001","username":"U.thhwomm3976"},"fp":"dF2VbD9dFnFlPH39pHl01zjP5JlEx7fgMSam9p+SB2b+zRjGXzGPo4rJvYKP47gnQQHesGMoMHUPeibwZ0ERjEt3VtZqDz6CEA+2H8t/xx5r3ut3oxAPNlKPHudRdK5IeZpNWtEFbekq9J5ODb+Ga112fK9BA2wKnSk2CzPCLBgS8fgoPuQAUTohvuFM3RFpEheDZtXEf9KLUE5gTNh+OAbO+NkU5NlUxc8e4DnYY4r20m09SrZ/1ZJ02Bs0P8ljQ+mM/dsHTMBzdR1IKnZ82p+YDl0l9RT6C6a23v9bVvOqv5OpLXnykXr38NbgHK/XXO5548gaOlUCf0T+9T7K/1QiswChF4G7utiY65/yBQPMgiHJBlbD7vkyi5uG4uk9y9qbgBTYJPwFWvxRoUH1ow==","uid":"8D781184-CC68-49AD-AE8E-CC14485E0C3E","gid":"8BACD822-8FC4-AEE9-94CA-C5E443A1AE67","vid":"80011327","pid":"10010","cid":"C1001","username":"U.thhwomm3976","uuid":"s_P33MGUMGH6C7PXSXV4FBD73ORM","lt":1,"releaseType":"release","hyVersionName":"3.20.0","patchVersion":"0","usid":"1524232512","sid":"89D7EF08-D7FA-0F9E-7A23-CDF0195926B6","hyVersion":"329","aid":"7CFE2AD4-91CF-49E3-B41D-478A42010462","versioninfo":"","bver":"6","becheck":"59F615DC4A3CC1C5E3796C5DDCAD1FA4DC42426D","betime":"1722231184157_2wakyi6mcjq542nx","bmagic":"ZkA4Ip0xBKquBr4kBG0KznkFRgaMDMD3XY8uThgC4OCSc4T/uda0XrBIY/BBG0i7AOo0EuAShi96rPApD43WUImqApZlZvC11Fxke7eSG4dq/hLyfWJkbYMJfYjpSp7tlZBqbrFhJi6q2FdxnoRraw==","activityId":"summerPromotion202407","prizeId":"24summer_ticket_new","sourcePlatform":"IOS"}'

response = requests.post('https://m.flight.qunar.com/gw/m/summerpromotion/exchange/exchange', headers = headers, data = data)

print(response.text)

b3nguang 发表于 2024-7-29 16:35

data = data改成json=data?

听雨在哭泣 发表于 2024-7-29 17:07

import requests

headers = {
    'Host': 'm.flight.qunar.com',
    'Content-Type': 'application/json; charset=UTF-8',
    'Origin': 'https://m.flight.qunar.com',
    'Accept-Encoding': 'gzip, deflate, br',
    'Cookie': 'QN270=8D781184-CC68-49AD-AE8E-CC14485E0C3E%2C80011327%2CC1001%2C8BACD822-8FC4-AEE9-94CA-C5E443A1AE67%2C10010%2C8D781184-CC68-49AD-AE8E-CC14485E0C3E%2C06B7442B-4F74-4FFB-A33A-4FD0C9137E6B; _q=U.thhwomm3976; _s=s_P33MGUMGH6C7PXSXV4FBD73ORM; _t=29184643; _v=wW_R9E1ZiPdxlRm5qLVWKnZVh7Bm7a3Ppa5CTCYQf2hr_LwKwQ5k8b41PHIDoWRgYbwGZwh3cq_lbITkhoO7wGekd2T4ijzD1J5zKVH3bUlyG2BW9pgSL84QjVDXBH7Zh98K0jTpFUuU9uwOb_EZvOh6v3OYouhxq5cggFeHmu-g; csrfToken=S4qtqWSJnjaYuc7; QN300=zn_summertask; cs_june=49a88f0dfa80248233f19bacf17fd1314d82f628a26c2bf469e77f9f74eda4482b03a3a09af637589c2fdeca103f398b87fad237f626b11f6f89ed85156d4cbeb17c80df7eee7c02a9c1a6a5b97c117927932a7f9e1526e317e0c2b675b866915a737ae180251ef5be23400b098dd8ca; ctf_june=1683616182042##iK3wVRDsVhPwawPwa%3DGTXPWIWRDsW%3DDAXsjsW%3DjsVDXsVKD8W2X%2BVPD%3DVPfRiK3siK3saKgwaS3saKv%2BaRgAVuPwaUvt; q_ckey=dT10aGh3b21tMzk3NiZrPUU0MjAyMDY4M0ZDQkUyMTVDQUYyQ0E0NUJBNTc0ODEzJnQ9MTcyMjIzMTAzNzk0MCZkPWVqYWJob3N0Mg==; QN233=; ctt_june=1683616182042##iK3waSPnVhPwawPwasERasEDaDPmXS2%2BVRHIaRkhaDD8aDiRVR3OaKgwEStwiK3siK3saKgwaKDmWRDNWstwawPwaUvt; QN48=tc_b105c19c397196c0_190be925640_d2a7; QN1=0000ef004138626dad9075fc',
    'Connection': 'keep-alive',
    'Accept': '*/*',
    'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 QunariPhone/80011327 m/9.2',
    'Referer': 'https://m.flight.qunar.com/shark/active/641e210d9448f9fb974f8fdf33cf94be',
    'Content-Length': '2688',
    'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
}

data = {"userIp": "",
      "clientGps": "37.37479782371633,122.16617583709194",
      "wifi_bssid": "6c:99:89:b1:73:1c",
      "wifiBssid": "6c:99:89:b1:73:1c",
      "wifi_ssid": "wifi",
      "wifiSsid": "wifi",
      "appInfo": {"fp": "dF2VbD9dFnFlPH39pHl01zjP5JlEx7fgMSam9p+SB2b+zRjGXzGPo4rJvYKP47gnQQHesGMoMHUPeibwZ0ERjEt3VtZqDz6CEA+2H8t/xx5r3ut3oxAPNlKPHudRdK5IeZpNWtEFbekq9J5ODb+Ga112fK9BA2wKnSk2CzPCLBgS8fgoPuQAUTohvuFM3RFpEheDZtXEf9KLUE5gTNh+OAbO+NkU5NlUxc8e4DnYY4r20m09SrZ/1ZJ02Bs0P8ljQ+mM/dsHTMBzdR1IKnZ82p+YDl0l9RT6C6a23v9bVvOqv5OpLXnykXr38NbgHK/XXO5548gaOlUCf0T+9T7K/1QiswChF4G7utiY65/yBQPMgiHJBlbD7vkyi5uG4uk9y9qbgBTYJPwFWvxRoUH1ow==", "uuid": "s_P33MGUMGH6C7PXSXV4FBD73ORM", "lt": 1, "uid": "8D781184-CC68-49AD-AE8E-CC14485E0C3E", "releaseType": "release", "hyVersionName": "3.20.0", "vid": "80011327", "cid": "C1001", "patchVersion": "0", "usid": "1524232512", "gid": "8BACD822-8FC4-AEE9-94CA-C5E443A1AE67", "sid": "89D7EF08-D7FA-0F9E-7A23-CDF0195926B6", "pid": "10010", "hyVersion": "329", "aid": "7CFE2AD4-91CF-49E3-B41D-478A42010462", "versioninfo": ""},
      "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_7_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 QunariPhone/80011327 m/9.2",
      "platform": "ios", "osVersion": "15.7.2", "modal": "iPhone9,2", "network": "wifi", "userIpNetworkType": "wifi", "channel": "APP",
      "userInfo": {"uid": "8D781184-CC68-49AD-AE8E-CC14485E0C3E", "gid": "8BACD822-8FC4-AEE9-94CA-C5E443A1AE67", "vid": "80011327", "pid": "10010", "cid": "C1001", "username": "U.thhwomm3976"},
      "fp": "dF2VbD9dFnFlPH39pHl01zjP5JlEx7fgMSam9p+SB2b+zRjGXzGPo4rJvYKP47gnQQHesGMoMHUPeibwZ0ERjEt3VtZqDz6CEA+2H8t/xx5r3ut3oxAPNlKPHudRdK5IeZpNWtEFbekq9J5ODb+Ga112fK9BA2wKnSk2CzPCLBgS8fgoPuQAUTohvuFM3RFpEheDZtXEf9KLUE5gTNh+OAbO+NkU5NlUxc8e4DnYY4r20m09SrZ/1ZJ02Bs0P8ljQ+mM/dsHTMBzdR1IKnZ82p+YDl0l9RT6C6a23v9bVvOqv5OpLXnykXr38NbgHK/XXO5548gaOlUCf0T+9T7K/1QiswChF4G7utiY65/yBQPMgiHJBlbD7vkyi5uG4uk9y9qbgBTYJPwFWvxRoUH1ow==",
      "uid": "8D781184-CC68-49AD-AE8E-CC14485E0C3E", "gid": "8BACD822-8FC4-AEE9-94CA-C5E443A1AE67", "vid": "80011327", "pid": "10010", "cid": "C1001",
      "username": "U.thhwomm3976", "uuid": "s_P33MGUMGH6C7PXSXV4FBD73ORM", "lt": 1, "releaseType": "release", "hyVersionName": "3.20.0", "patchVersion": "0", "usid": "1524232512",
      "sid": "89D7EF08-D7FA-0F9E-7A23-CDF0195926B6", "hyVersion": "329", "aid": "7CFE2AD4-91CF-49E3-B41D-478A42010462", "versioninfo": "", "bver": "6", "becheck": "59F615DC4A3CC1C5E3796C5DDCAD1FA4DC42426D",
      "betime": "1722231184157_2wakyi6mcjq542nx", "bmagic": "ZkA4Ip0xBKquBr4kBG0KznkFRgaMDMD3XY8uThgC4OCSc4T/uda0XrBIY/BBG0i7AOo0EuAShi96rPApD43WUImqApZlZvC11Fxke7eSG4dq/hLyfWJkbYMJfYjpSp7tlZBqbrFhJi6q2FdxnoRraw==",
      "activityId": "summerPromotion202407", "prizeId": "24summer_ticket_new", "sourcePlatform": "IOS"}

response = requests.post('https://m.flight.qunar.com/gw/m/summerpromotion/exchange/exchange', headers=headers, json=data)
print(response.text)

{"status":10111,"message":"未通过实名认证","data":null}不知道是不是你的结果

weiback 发表于 2024-7-29 19:51

可以使用pycurl库发送请求试一下

cy07483 发表于 2024-7-29 20:06

听雨在哭泣 发表于 2024-7-29 17:07
import requests

headers = {


就是要这个结果,非常感谢
页: [1]
查看完整版本: curl命令转成python运行就出错是怎么回事