JustalK / PORNHUB-API

A powerful and complete scrapper for the very famous pornhub.com. This javascript module for node give you the possibility, through an API with many options, to scrap any information out of a page or the search page.
MIT License
130 stars 29 forks source link

[BUG] Cannot read property 'textContent' of null #47

Closed Alejandro12120 closed 3 years ago

Alejandro12120 commented 3 years ago

Describe the bug This bug happens rarely but when it happens you can't get information about the video.

To Reproduce

let videos = [];
let urls = JSON.parse(fs.readFileSync("./videos.json"));

pornhub.page(urls[0], ['title', 'thumbnail_url']).then(video => {
        videos.push(video);
        urls.shift();
        removeNext(urls);
});

function removeNext(urls) {
    if (typeof urls !== 'undefined' && urls.length === 0) {
        console.log("Done");

        return;
    }

    pornhub.page(urls[0], ['title', 'thumbnail_url']).then(video => {
        videos.push(video);

        urls.shift();

        removeNext(urls);
    });
}

Full error log

TypeError: Cannot read property 'textContent' of null
    at Object.scrap_javascript (C:\Users\Alejandro\Desktop\x\node_modules\@justalk\pornhub-api\src\helpers\utils_scrap.js:36:52)
    at C:\Users\Alejandro\Desktop\x\node_modules\@justalk\pornhub-api\src\helpers\utils_scrap.js:52:39
    at Array.map (<anonymous>)
    at Object.scrap (C:\Users\Alejandro\Desktop\x\node_modules\@justalk\pornhub-api\src\helpers\utils_scrap.js:45:47)
    at Object.scraper_content_informations (C:\Users\Alejandro\Desktop\x\node_modules\@justalk\pornhub-api\src\helpers\utils_scrap.js:10:25)
    at Object.scraping_page (C:\Users\Alejandro\Desktop\x\node_modules\@justalk\pornhub-api\src\page.js:59:37)
    at Object.page (C:\Users\Alejandro\Desktop\x\node_modules\@justalk\pornhub-api\src\index.js:23:23)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Alejandro12120 commented 3 years ago

Well apparently the error was fixed.