This article is a kind of stuffed text that you write in anger after experiencing a situation in which the original text is deleted while writing an answer. ๐
var client = require('cheerio-httpcli');
let request = require('request');
constjson = '{"portal":"next",title":"drinking"}' //input data
const obj = JSON.parse(json);
console.log('obj.title: [' + obj.title + ']');
var url = 'http://webtoon.daum.net/data/pc/search?q=' + obj.title + '&page_no=1';
client.fetch(url, {}, function (err, $, res, body) {
console.log('err:', err);
console.log('$:', $);
});
const getArticlesTitle = (url) => {
request({ url: url }, function (error, response, body) {
console.log('body:', body);
});
};
getArticlesTitle(url);
If you run the above code as nodejs:
TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters
at new ClientRequest (_http_client.js:139:13)
at Object.request (http.js:44:10)
at Request.start (C:\dev\cheerio-test\node_modules\request\request.js:751:32)
at Request.end (C:\dev\cheerio-test\node_modules\request\request.js:1511:10)
at end (C:\dev\cheerio-test\node_modules\request\request.js:564:14)
at Immediate._onImmediate (C:\dev\cheerio-test\node_modules\request\request.js:578:7)
at processImmediate (internal/timers.js:439:21) {
url: 'http://webtoon.daum.net/data/pc/search?q=Eating&page_no=1'
}
This error occurs. What's wrong with this?
node.js javascript
Replace url's Korean:
var url = 'http://webtoon.daum.net/data/pc/search?q='
+ + encodeURI(obj.title)
+ + '&page_no=1';
ยฉ 2024 OneMinuteCode. All rights reserved.