cuốn sách gpt4 ai đã làm

ssl - "hostname doesn' t匹配“在PythonAnywhere中使用请求时

In lại Tác giả: Vũ trụ không gian 更新时间:2023-11-03 13:51:14 27 4
mua khóa gpt4 Nike

biên tập:我解决了问题,请参阅答案中的链接。

tôi đang sử dụng XMLHttpRequest AJAX API 将来自不同网站的数据发送到我们在 PythonAnywhere 中的服务器。奇怪的事情发生了:根据网站的不同,要么我们发送成功,要么我们得到这个错误

POST https://canecto.pythonanywhere.com/api/ 500 (Internal Server Error)

即使加载了相同的代码。我尝试在 Chrome 中通过 JavaScript 控制台手动打开请求并发送数据,但没有任何变化。

代码片段如下所示:

var url = "https://canecto.pythonanywhere.com/api/";
var xmlHttpPost = new XMLHttpRequest();
xmlHttpPost.open("POST", url, true);
xmlHttpPost.setRequestHeader("Content-type", "application/json");

var postData = {
page_url: window.location.href,
time_on_page: activeTime,
cookie: cookie,
/* some variables */
};
xmlHttpPost.onreadystatechange = function() {
if (xmlHttpPost.readyState == 4 && XMLHttpRequest.DONE) {
console.log('');
}
};

/* send data */
xmlHttpPost.send(JSON.stringify(postData));

我读了đây问题不应该是客户端 JavaScript。

如果我在服务器端检查,对于行 requests.get(page_url, headers=HEADER, timeout=10)(我尝试访问页面的地方)我得到这个日志:

nhập mô tả hình ảnh ở đây

tôi ở đây Python request library 上阅读这可能与 SSL 验证有关,但我对此知之甚少。我试图检查其他类似的问题,但我没有找到答案。

有没有人遇到过类似的事情并成功解决了?

câu trả lời hay nhất

给它仍然使用 Python < 2.7.9 的人:câu trả lời này为我工作。 Python 2 不支持 SNI,这意味着您应该遵循这样的答案和 these requirements使请求与 SSL 证书验证一起工作。

关于ssl - "hostname doesn' t匹配“在PythonAnywhere中使用请求时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44108573/

27 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress