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;
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
add a comment |
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
It seems the error means you do not declarepages
variable. Tryconst pages = await browser.pages();
instead.
– vsemozhetbyt
Mar 28 at 17:44
add a comment |
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
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
javascript node.js web-scraping puppeteer
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 declarepages
variable. Tryconst pages = await browser.pages();
instead.
– vsemozhetbyt
Mar 28 at 17:44
add a comment |
It seems the error means you do not declarepages
variable. Tryconst 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
add a comment |
1 Answer
1
active
oldest
votes
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);
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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);
add a comment |
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);
add a comment |
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);
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);
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
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
It seems the error means you do not declare
pages
variable. Tryconst pages = await browser.pages();
instead.– vsemozhetbyt
Mar 28 at 17:44