如何解决未经授权的请求(401响应)?
我正在尝试使用GET和发布方法从网站上进行一些刮擦,但是现在我面临着一个新的挑战。
我试图从信用模拟器中获取数据,我找到了这个葡萄牙网站( https:/https:/ /www.wizink.pt/public/credito-pessoal#/ )。
据我所知,我需要使用Post方法,但是我只能获得401响应。
这是我的代码:
from openpyxl import load_workbook
import requests
import numpy as np
import time
from datetime import datetime
import pandas as pd
import json
import warnings
warnings.filterwarnings("ignore")
url_Wizink = 'https://www.creditopessoal.wizink.pt/gravitee/gateway/api-chn-loans/v1/loans/quotation'
headers_WiZink = {'Accept': 'application/json',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'pt-PT',
'Authorization': 'Bearer 978131ab-8acd-4671-bfaf-ae325d148adf',
'Connection': 'keep-alive',
'Content-Length': '266',
'Content-Type': 'application/json;charset=UTF-8',
'Host': 'www.creditopessoal.wizink.pt',
'Origin': 'https://www.wizink.pt',
'Referer': 'https://www.wizink.pt/',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
'sec-ch-ua-mobile': '?0',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36',
'X-Channel-Id': 'LOANSIMULATOR',
'X-Client-Id': 'simWzkPt',
'X-Country-Id': 'PRT',
'X-Device-UUID': 'd14e9b629804cbba1ac7c3e78ab39a56'}
payload_Wizink = {"productCode":"WZP01","fixedTermLoanId":"0024","impositionAmount":{"amount":5500,"currency":"EUR"},"settlementDay":"5","dueOrAdvanceInterestIndicator":"3",
"nominalInterest":"8.0000000","feeRateId":"05","settlementFrequencyId":"0001","deprecationFrequencyId":"0001"}
response_Wizink = requests.post(url_Wizink, headers=headers_WiZink, data=payload_Wizink, verify=False)
关于问题是什么的想法?
I am trying to do some scraping from websites using GET and POST methods, but now I am facing a new challenge.
I am trying to get data from a credit simulator, I found this portuguese site (https://www.wizink.pt/public/credito-pessoal#/).
As far as I know, I need to use POST method,but I am only getting 401 for the response.
Here is my code:
from openpyxl import load_workbook
import requests
import numpy as np
import time
from datetime import datetime
import pandas as pd
import json
import warnings
warnings.filterwarnings("ignore")
url_Wizink = 'https://www.creditopessoal.wizink.pt/gravitee/gateway/api-chn-loans/v1/loans/quotation'
headers_WiZink = {'Accept': 'application/json',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'pt-PT',
'Authorization': 'Bearer 978131ab-8acd-4671-bfaf-ae325d148adf',
'Connection': 'keep-alive',
'Content-Length': '266',
'Content-Type': 'application/json;charset=UTF-8',
'Host': 'www.creditopessoal.wizink.pt',
'Origin': 'https://www.wizink.pt',
'Referer': 'https://www.wizink.pt/',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"',
'sec-ch-ua-mobile': '?0',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36',
'X-Channel-Id': 'LOANSIMULATOR',
'X-Client-Id': 'simWzkPt',
'X-Country-Id': 'PRT',
'X-Device-UUID': 'd14e9b629804cbba1ac7c3e78ab39a56'}
payload_Wizink = {"productCode":"WZP01","fixedTermLoanId":"0024","impositionAmount":{"amount":5500,"currency":"EUR"},"settlementDay":"5","dueOrAdvanceInterestIndicator":"3",
"nominalInterest":"8.0000000","feeRateId":"05","settlementFrequencyId":"0001","deprecationFrequencyId":"0001"}
response_Wizink = requests.post(url_Wizink, headers=headers_WiZink, data=payload_Wizink, verify=False)
Any ideas on what the problem is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个请求。尝试更改帖子以获取。
它在邮递员的卷发中对我有用:
It is a GET request. Try to change POST for GET.
It works for me in postman with this curl: