Scraperjsを使用して、現在、charset ISO-8859-1でウェブサイトをスクラップしています。私の問題は、æ、ø、å、éなどの文字が適切にエンコードされていないことです(疑問符で表示/保存されます)。Scraperjsでスクレイピングするときに間違った文字セット
アイデア?
Scraperjs: https://github.com/ruipgil/scraperjs
Scraperjsを使用して、現在、charset ISO-8859-1でウェブサイトをスクラップしています。私の問題は、æ、ø、å、éなどの文字が適切にエンコードされていないことです(疑問符で表示/保存されます)。Scraperjsでスクレイピングするときに間違った文字セット
アイデア?
Scraperjs: https://github.com/ruipgil/scraperjs
は、ソリューションを自分自身を発見しました。表示されている文字を読むためには、エンコーディングをバイナリに指定する必要があります。以下のコードを参照してください。
scraperjs.StaticScraper.create()
.request({ url:"http://vg.no", encoding: "binary"})
.scrape(function($) {
return $("p").map(function() {
return $(this);
});
})
.then(function(domElements).........
const scraperjs = require('scraperjs');
const urlToScrape = 'http://www.somesite.com';
const selectorToScrape = "div#someId";
scraperjs.StaticScraper.create({
url: urlToScrape,
encoding: "binary"
}).scrape(function ($) {
return $(selectorToScrape).map(function() {
return $(this).text();
}).get();
}).then(function (result) {
console.log(result);
});