Puppeteer

Unable to let my script perform all the clicks on the next page button

核能气质少年 提交于 2019-12-11 17:35:24
问题 I've created a script in python using pyppeteer to collect the names of different institutions traversing multiple pages from a website. What I wish to do is let my script rove different pages by clicking on the next page button while parsing the names from each page. website address What I've tried: import asyncio from pyppeteer import launch url = "https://www.incometaxindia.gov.in/Pages/utilities/exempted-institutions.aspx" async def fetch_table(link): browser = await launch(headless=False

Switching between tabs in puppeteer

落爺英雄遲暮 提交于 2019-12-11 16:55:35
问题 How to switch between current opened tab to the parent tab using puppeteer? I have a home page and when i click on the link in home page it opens a new tab. After that page is loading i need to switch to home page. 回答1: You can use the browser.pages() method, it returns a promise which resolves to an array of all open pages. const firstTab = (await browser.pages())[0]; const secondTab = (await browser.pages())[1]; Also, you can use event popup , emitted when the page opens a new tab or window

How to use .$$eval function

一世执手 提交于 2019-12-11 16:42:36
问题 I'm trying to run this code: var aaa = await page.$$eval(selector, list => (list, value) => { return resolve(list.find(element => element.textContent === value)); } ,value); But I received an error. Therefore, I tried to print the items in "list" (because I assumed that the problem is there), I tried this code: var aaa = await page.$$eval(selector, list => list); And I received that "aaa" is empty. Any idea what may be the problem? 回答1: You are attempting to return DOM elements from page.$

Testing puppeteer with Jasmine?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 15:53:03
问题 We have a website that has many paths of flow (login , signup , payment ,etc) We're using puppeteer scripts ( typescript via node) to automate-testing our website behaviour (full flow) , and when we get an error (or unexpected result) we're sending email or some kind of alerts. But I see that people also use jasmine with puppeteer. For example : const puppeteer = require('puppeteer'); describe("Jasmine puppeteer", function() { let browser; let page; beforeAll(() => { browser = await puppeteer

Extracting text from a <p> tag within an iframe with Puppeteer

别来无恙 提交于 2019-12-11 15:48:47
问题 I'm having some difficulties extracting text from within an iframe. Given the code: <iframe id="iframe" src="https://myamazingapp/2637374848489595" style="width:100%;border:none" height="858px" css="1"></iframe> <div id="document"> <html lang ="en"> <head>...</head> <body onLoad="resize();"> <div>class = "app"> <div class = my-response"> <div class="my-response__iconcontainer>.. </div> <div class="my-response__copy"> <p>Thank you for filling out my form</p> </div> </div> </div>//....other

Puppeteer Does Not Visualise Complete SVG Chart

只谈情不闲聊 提交于 2019-12-11 15:14:42
问题 I am using this code in Try Puppeteer: const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://www.barchart.com/futures/quotes/ESM19/interactive-chart/fullscreen'); const linkHandlers = await page.$x("//li[contains(text(), '1D')]"); if (linkHandlers.length > 0) { await linkHandlers[0].click(); } else { throw new Error("Link not found"); } await page.$eval('input[name="fieldInput"]', el => el.value = '1'); console.log(await page.content()) //

Puppeteer Select Link

此生再无相见时 提交于 2019-12-11 12:09:41
问题 I want to click on a link in a html page, which contains following snippet: <p>Die maximale Trefferanzahl von 200 wurde überschritten. <a href="/rp_web/search.do?doppelt">Verdoppeln Sie hier Suchergebnislimit.</a> </p> I'm setting some filters before and then I am loading the page, which loads the page I need. On that resulting page, I want to click on the link as seen in the html snippet. The js I'm trying to use is this one await Promise.all([ page.click('input#landNW'), // set a filter

Puppeteer pdf blank on Heroku

☆樱花仙子☆ 提交于 2019-12-11 09:53:05
问题 I'm making a route in my webapp that turns some html into a pdf. This works great in development, but fails on Heroku. Other Puppeteer tasks work fine on heroku. The HTML I'm rendering is quite small. const generatePDF = asyncMiddleware(async (req, res) => { const browser = await puppeteer.launch({ dumpio: true, headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] }); const page = await browser.newPage(); page.on('error', err => { console.error('err', err, err.stack) browser

how to add urls to Flash white list in puppeteer

耗尽温柔 提交于 2019-12-11 09:20:10
问题 I develop small crawler with puppeteer in Node.js. the target site has Flash contents, so I want to enable Flash in puppeteer. by default, puppeteer is unable to use Flash and white list of permitted sites is empty. I know how to enable Flash in puppeteer, but I don't know how to set white list. How to do that? Is there flag like this? const browser = await puppeteer.launch({ headless: false, args: [ '--ppapi-flash-path = {FLASH_PATH}', '--white-url = {TARGET_URL}' ] }); Or, is it only way to

Cloud Functions puppeteer Error: net::ERR_NAME_RESOLUTION_FAILED at http://www.google.com

喜夏-厌秋 提交于 2019-12-11 06:02:01
问题 On google Cloud Functions when I try to use puppeteer I get the following error for all sites that I try, an example for google.com: Error: net::ERR_NAME_RESOLUTION_FAILED at http://www.google.com at navigate (/srv/node_modules/puppeteer/lib/FrameManager.js:101:37) at <anonymous> at process._tickDomainCallback (internal/process/next_tick.js:229:7) -- ASYNC -- at Frame.<anonymous> (/srv/node_modules/puppeteer/lib/helper.js:110:27) at Page.goto (/srv/node_modules/puppeteer/lib/Page.js:656:49)