【发布时间】:2022-08-07 23:32:22
【问题描述】:
我正在尝试向网站提交付款,我需要获取返回的 Location 标头。我试过allow_redirects=False,但我没有得到返回的标题。大多数帖子都带有会话,所以我尝试了会话和请求。
返回的标头:
{\'Allow\': \'HEAD, GET\', \'Content-Length\': \'0\', \'Server\': \'\', \'Expires\': \'Wed, 13 Apr 2022 01:34:32 GMT\', \'Cache-Control\': \'max-age=0, no-cache, no-store\', \'Pragma\': \'no-cache\', \'Date\': \'Wed, 13 Apr 2022 01:34:32 GMT\', \'Connection\': \'keep-alive\', \'Server-Timing\': \'cdn-cache; desc=MISS, edge; dur=11, origin; dur=7\', \'Strict-Transport-Security\': \'max-age=31536000 ; includeSubDomains\'}
铬标题:
cache-control: max-age=0, no-cache, no-store
content-length: 0
date: Wed, 13 Apr 2022 00:48:21 GMT
expires: Wed, 13 Apr 2022 00:48:21 GMT
location: https://www.bigw.com.au/checkout/webpay/success?dts_reference=5000000315110950
pragma: no-cache
server
server-timing: cdn-cache; desc=MISS
server-timing: edge; dur=11
server-timing: origin; dur=197
set-cookie: AKA_A2=A; expires=Wed, 13-Apr-2022 01:48:21 GMT; path=/; domain=payments.woolworths.com.au; secure; HttpOnly
strict-transport-security: max-age=31536000 ; includeSubDomains
我的代码:
headers = {
\'authority\': \'iframe.payments.woolworths.com.au\',
\'method\': \'POST\',
\'path\': \'/WOWPaymentService/webservice/continueSecureData\',
\'scheme\': \'https\',
\'accept\': \'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\',
\'accept-encoding\': \'gzip, deflate, br\',
\'accept-language\': \'en-GB,en;q=0.9\',
\'cache-control\': \'max-age=0\',
\'content-length\': \'147\',
\'content-type\': \'application/x-www-form-urlencoded\',
\'dnt\': \'1\',
\'origin\': \'https://iframe.payments.woolworths.com.au\',
\'referer\': link_full,
\'sec-ch-ua\': \'\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"100\", \"Google Chrome\";v=\"100\"\',
\'sec-ch-ua-mobile\': \'?0\',
\'sec-ch-ua-platform\': \'\"Windows\"\',
\'sec-fetch-dest\': \'iframe\',
\'sec-fetch-mode\': \'navigate\',
\'sec-fetch-site\': \'same-origin\',
\'sec-fetch-user\': \'?1\',
\'upgrade-insecure-requests\': \'1\',
\'user-agent\': \'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36\'
}
payload = {
\'card_number\': \'4007000000027\',
\'exp_month\': \'04\',
\'exp_year\': \'2023\',
\'cv2_number\': \'456\',
\'HPS_SessionID\': str(link),
\'issue_number\': \'\',
\'action\': \'confirm\'
}
r = requests.post(\"https://iframe.payments.woolworths.com.au/WOWPaymentService/webservice/continueSecureData\", allow_redirects=True, verify=False, json=payload, headers=headers, timeout=10)
print(r.url)
print(r.headers)
对不起,它被标记了????
任何帮助表示赞赏!
标签: python python-3.x python-requests python-requests-html