Scrap page open in new tab using puppeterJavaScript open in a new window, not tabHow do I modify the URL without reloading the page?Scroll to the top of the page using JavaScript/jQuery?What is the 'new' keyword in JavaScript?Get the size of the screen, current web page and browser windowOpen a URL in a new tab (and not a new window) using JavaScriptHow can I refresh a page with jQuery?How can I add new array elements at the beginning of an array in Javascript?Unable to choose by selectors using PuppeteerHow to click on all elements and wait for each of them to finish their AJAX request to scrape data? (AJAX is loaded in the same element each time)

Should I tip on the Amtrak train?

Why did Boris Johnson call for new elections?

Friend is very nit picky about side comments I don't intend to be taken too seriously

What makes an ending "happy"?

Why are some hotels asking you to book through Booking.com instead of matching the price at the front desk?

Short story: Interstellar inspector senses "off" nature of planet hiding aggressive culture

How do German speakers decide what should be on the left side of the verb?

Male viewpoint in an erotic novel

Passport - tiny rip on the edge of my passport page

If every star in the universe except the Sun were destroyed, would we die?

Is there some sort of French saying for "a person's signature move"?

Filling attribute tables with values from the same attribute table

How can I know what hashing algorithm SQL Server used to decrypt the encrypted data when using the function DECRYPTBYPASSPHRASE?

Professor refuses to write a recommendation letter to students who haven't written a research paper with him

Examples where "thin + thin = nice and thick"

How can I hint that my character isn't real?

Are fast interviews red flags?

I multiply the source, you (probably) multiply the output!

Let A,B,C be sets. If A△B=A△C, does this imply that B=C?

What quests do you need to stop at before you make an enemy of a faction for each faction?

How do English-speaking kids loudly request something?

After a few interviews, What should I do after told to wait?

How to interpret or parse this confusing 'NOT' and 'AND' legal clause

Entering the US with dual citizenship but US passport is long expired?



Scrap page open in new tab using puppeter


JavaScript open in a new window, not tabHow do I modify the URL without reloading the page?Scroll to the top of the page using JavaScript/jQuery?What is the 'new' keyword in JavaScript?Get the size of the screen, current web page and browser windowOpen a URL in a new tab (and not a new window) using JavaScriptHow can I refresh a page with jQuery?How can I add new array elements at the beginning of an array in Javascript?Unable to choose by selectors using PuppeteerHow to click on all elements and wait for each of them to finish their AJAX request to scrape data? (AJAX is loaded in the same element each time)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a list of item on page now on click on each item new tab is opened, which I need to parse and get back to original page and then click the next item. So this need to be done repeatedly for all item. The code is mentioned below:



for(let k =0 ;k<item_arr.length;k++) 

let item_id = item_arr[k];
console.log("=====inside for loop======");
console.log("=====ITEM ID:::::======"+item_id);

try

console.log("=====before click======");

let item_d = await page.$('div[id="'+item_id+'"]');
await item_d.click();
console.log("=====after click======");


catch (e)

console.log("Error >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> :"+e);


pages = await browser.pages();
count = pages.length;
console.log("==========count number of pages"+count);




I am getting error as mentioned below:



(node:12280) UnhandledPromiseRejectionWarning: ReferenceError: pages is not defined


So how to handle the scraping?










share|improve this question


























  • It seems the error means you do not declare pages variable. Try const pages = await browser.pages(); instead.

    – vsemozhetbyt
    Mar 28 at 17:44


















0















I have a list of item on page now on click on each item new tab is opened, which I need to parse and get back to original page and then click the next item. So this need to be done repeatedly for all item. The code is mentioned below:



for(let k =0 ;k<item_arr.length;k++) 

let item_id = item_arr[k];
console.log("=====inside for loop======");
console.log("=====ITEM ID:::::======"+item_id);

try

console.log("=====before click======");

let item_d = await page.$('div[id="'+item_id+'"]');
await item_d.click();
console.log("=====after click======");


catch (e)

console.log("Error >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> :"+e);


pages = await browser.pages();
count = pages.length;
console.log("==========count number of pages"+count);




I am getting error as mentioned below:



(node:12280) UnhandledPromiseRejectionWarning: ReferenceError: pages is not defined


So how to handle the scraping?










share|improve this question


























  • It seems the error means you do not declare pages variable. Try const pages = await browser.pages(); instead.

    – vsemozhetbyt
    Mar 28 at 17:44














0












0








0








I have a list of item on page now on click on each item new tab is opened, which I need to parse and get back to original page and then click the next item. So this need to be done repeatedly for all item. The code is mentioned below:



for(let k =0 ;k<item_arr.length;k++) 

let item_id = item_arr[k];
console.log("=====inside for loop======");
console.log("=====ITEM ID:::::======"+item_id);

try

console.log("=====before click======");

let item_d = await page.$('div[id="'+item_id+'"]');
await item_d.click();
console.log("=====after click======");


catch (e)

console.log("Error >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> :"+e);


pages = await browser.pages();
count = pages.length;
console.log("==========count number of pages"+count);




I am getting error as mentioned below:



(node:12280) UnhandledPromiseRejectionWarning: ReferenceError: pages is not defined


So how to handle the scraping?










share|improve this question
















I have a list of item on page now on click on each item new tab is opened, which I need to parse and get back to original page and then click the next item. So this need to be done repeatedly for all item. The code is mentioned below:



for(let k =0 ;k<item_arr.length;k++) 

let item_id = item_arr[k];
console.log("=====inside for loop======");
console.log("=====ITEM ID:::::======"+item_id);

try

console.log("=====before click======");

let item_d = await page.$('div[id="'+item_id+'"]');
await item_d.click();
console.log("=====after click======");


catch (e)

console.log("Error >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> :"+e);


pages = await browser.pages();
count = pages.length;
console.log("==========count number of pages"+count);




I am getting error as mentioned below:



(node:12280) UnhandledPromiseRejectionWarning: ReferenceError: pages is not defined


So how to handle the scraping?







javascript node.js web-scraping puppeteer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 17:41









vsemozhetbyt

2,6308 silver badges12 bronze badges




2,6308 silver badges12 bronze badges










asked Mar 28 at 6:13









SwapnilSwapnil

13 bronze badges




13 bronze badges















  • It seems the error means you do not declare pages variable. Try const pages = await browser.pages(); instead.

    – vsemozhetbyt
    Mar 28 at 17:44


















  • It seems the error means you do not declare pages variable. Try const pages = await browser.pages(); instead.

    – vsemozhetbyt
    Mar 28 at 17:44

















It seems the error means you do not declare pages variable. Try const pages = await browser.pages(); instead.

– vsemozhetbyt
Mar 28 at 17:44






It seems the error means you do not declare pages variable. Try const pages = await browser.pages(); instead.

– vsemozhetbyt
Mar 28 at 17:44













1 Answer
1






active

oldest

votes


















0
















I think pages is an object and not an array so needs to be addressed as,



Object.keys(pages).length


I load pages/tabs like this, which might not be of use.



const pages = await browser.pages();
await pages[0].setViewport( width: 1280, height: 1080 )
await pages[0].goto(URL);





share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391183%2fscrap-page-open-in-new-tab-using-puppeter%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0
















    I think pages is an object and not an array so needs to be addressed as,



    Object.keys(pages).length


    I load pages/tabs like this, which might not be of use.



    const pages = await browser.pages();
    await pages[0].setViewport( width: 1280, height: 1080 )
    await pages[0].goto(URL);





    share|improve this answer































      0
















      I think pages is an object and not an array so needs to be addressed as,



      Object.keys(pages).length


      I load pages/tabs like this, which might not be of use.



      const pages = await browser.pages();
      await pages[0].setViewport( width: 1280, height: 1080 )
      await pages[0].goto(URL);





      share|improve this answer





























        0














        0










        0









        I think pages is an object and not an array so needs to be addressed as,



        Object.keys(pages).length


        I load pages/tabs like this, which might not be of use.



        const pages = await browser.pages();
        await pages[0].setViewport( width: 1280, height: 1080 )
        await pages[0].goto(URL);





        share|improve this answer















        I think pages is an object and not an array so needs to be addressed as,



        Object.keys(pages).length


        I load pages/tabs like this, which might not be of use.



        const pages = await browser.pages();
        await pages[0].setViewport( width: 1280, height: 1080 )
        await pages[0].goto(URL);






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 28 at 10:06

























        answered Mar 28 at 9:35









        HellonearthisHellonearthis

        8201 gold badge8 silver badges19 bronze badges




        8201 gold badge8 silver badges19 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















            draft saved

            draft discarded















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55391183%2fscrap-page-open-in-new-tab-using-puppeter%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현