'DOMParser is not working in certain websites
I'm making a chrome extension.
I'm trying to get some pages' html through the javascript.
I found the code I can use in this site.
Here is the code:
fetch(url)
.then(function (response) { // When the page is loaded convert it to text
return response.text()
})
.then(function (html) { // Initialize the DOM parser
const parser = new DOMParser(); // Parse the text
const doc = parser.parseFromString(html, "text/html");
console.log(doc);
})
.catch(function (err) {
console.log('Failed to fetch page: ', err);
});
Luckily, in most websites this code works well, but in a certain site this doesn't work well.
Here is the link I have problem with: https://ja.dict.naver.com/#/entry/jako/c650d30f378b49dca0ecd6ea85fcc258
I want all nodes' texts but through this code, the "body" part doesn't show up.
I have searched google, this site and other reference but I can't found the solution and don't know why.
Isn't there way to solve this problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
