Created
November 13, 2018 18:48
-
-
Save RoyiNamir/f87637161ee02b8f6c790bc9b6a4097c to your computer and use it in GitHub Desktop.
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 characters
import puppeteer, {ElementHandle} from "puppeteer"; | |
(async () => | |
{ | |
const browser = await puppeteer.launch({headless: false}); | |
const page = await browser.newPage(); | |
let url = "https://www.mutualart.com/Artists"; | |
console.log(`Fetching page data for : ${url}...`); | |
await page.goto(url); | |
await page.waitForSelector(".item.col-xs-3"); | |
let arrMainLinks: ElementHandle[] = await page.$$('.item.col-xs-3 > a'); | |
console.log(arrMainLinks.length); | |
for (let mainLink of arrMainLinks) //get the main links | |
{ | |
let hrefValue =await (await mainLink.getProperty('href')).jsonValue(); | |
console.log("Clicking on " + hrefValue); | |
await Promise.all([ | |
page.waitForNavigation(), | |
mainLink.click({delay: 100}) | |
]); | |
let arrSubLinks: ElementHandle[] = await page.$$('.slide >a'); | |
//let's click on each sub click | |
for (let sublink of arrSubLinks) | |
{ | |
console.log('███AAA'); | |
await Promise.all([ | |
page.waitForNavigation(), | |
sublink.click({delay: 100}) | |
]); | |
console.log('███BBB'); | |
// await page.goBack() | |
break; | |
} | |
break; | |
} | |
await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment