此代码不会在控制台中显示 html 它会显示错误
var request = require('request');
var thai_url = "http://pantip.com/tag/Honda_(มอเตอร์ไซค์)";
request(thai_url, function (error, response, html) {
if (!error && response.statusCode === 200) {
console.log(html);
} else {
console.log("Error");
}
});
但是我将 thai_url 从 มอเตอร์ไซค์ 更改为 %E0%B8%A1%E0%B8%AD%E0%B9%80%E0%B8%95%E0%B8%AD%E0%B8%A3%E0%B9%8C% E0%B9%84%E0%B8%8B%E0%B8%84%E0%B9%8C
像这样
var request = require('request');
var thai_url = "http://pantip.com/tag/Honda_(%E0%B8%A1%E0%B8%AD%E0%B9%80%E0%B8%95%E0%B8%AD%E0%B8%A3%E0%B9%8C%E0%B9%84%E0%B8%8B%E0%B8%84%E0%B9%8C)";
request(thai_url, function (error, response, html) {
if (!error && response.statusCode === 200) {
console.log(html);
} else {
console.log("Error");
}
});
第二个代码工作正常。我可以将มอเตอไซค์更改为%E0%B8%A1%E0%B8...(更多)吗?或者如果可能的话,我如何使用 npm request为http://pantip.com/tag/Honda_(มอเตอร์ไซค์)工作?感谢您的任何帮助。