Last active
February 3, 2019 18:10
-
-
Save vsemozhetbyt/5b1afdbc90b79cb50127907327218b8b to your computer and use it in GitHub Desktop.
Revisions
-
vsemozhetbyt revised this gist
Feb 3, 2019 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,9 +29,9 @@ const puppeteer = require('puppeteer'); await Promise.all([doSearch, isSearchComplete]); const data = await resultsFrame.evaluate( () => document.querySelector('div.innerPageWrapper table').innerText ); console.log(data.trim().replace(/\s+/g, ' ')); -
vsemozhetbyt renamed this gist
Feb 3, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
vsemozhetbyt created this gist
Feb 3, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ 'use strict'; const puppeteer = require('puppeteer'); (async function main() { try { const browser = await puppeteer.launch(); const [page] = await browser.pages(); await page.goto('https://www.fmponline.com/ecomm/Shop'); const inputs = { manufacturer: 'PITCO', partNumber: '60125401', }; const searchFrame = page.frames().find(frame => frame.name() === 'contentsframe0'); const resultsFrame = page.frames().find(frame => frame.name() === 'mainframe'); const doSearch = searchFrame.evaluate((inputs) => { [...document.querySelectorAll('select#searchBox_manufacturer > option')] .find(({ innerText }) => innerText === inputs.manufacturer) .selected = true; document.querySelector('input#searchBox_partNumber').value = inputs.partNumber; document.querySelector('input#searchButton').click(); }, inputs); const isSearchComplete = resultsFrame.waitForSelector('div.innerPageWrapper table'); await Promise.all([doSearch, isSearchComplete]); const data = await resultsFrame.evaluate(() => { return document.querySelector('div.innerPageWrapper table').innerText; }); console.log(data.trim().replace(/\s+/g, ' ')); await browser.close(); } catch (err) { console.error(err); } })();