for some reason, my querySelectorAll() returns no elements, but when I do it in the chrome console, I get all of the elements :o Could anyone explain this behavior? I'm assuming I'm missing something, maybe a script is loading up all of the elements before the actual website is fully loaded? :o
.then(e=>{
//e prints out the website text
const result = new JSDOM(e);
const document = result.window.document;
const redditPosts = document.querySelectorAll('.rpBJOHq2PR60pnwJlUyP0 > div');
//Reddit posts is empty HTMLDivElements
//Should be filled
})
Usually if it works in the browser and not with server side code it's because you're trying to get elements that are renedered with JavaScript
Обсуждают сегодня