Код: Выделить всё
var DOMParser = require('xmldom').DOMParser;
fetch('http://books.toscrape.com/index.html')
.then(response => {
return response.text()
})
.then(html => {
const parser = new DOMParser()
const doc = parser.parseFromString(html, "text/html")
const elem = doc.querySelector('.thumbnail').innerHTML
console.log(elem)
})
.catch(error => {
console.error('error:', error)
})
< /code>
Это возвращает следующую ошибку: < /p>
error: TypeError: doc.querySelector is not a function
at /home/petal/Desktop/scrapetest.js:11:22
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Спасибо и желаю вам хорошего дня c:
Подробнее здесь: https://stackoverflow.com/questions/796 ... tion-error
Мобильная версия