Created
June 9, 2021 02:33
-
-
Save defp/e04ecb44deb60a93d8b33a1d736c6361 to your computer and use it in GitHub Desktop.
puppeteer demo
This file contains 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
const puppeteer = require('puppeteer'); | |
(async () => { | |
const browser = await puppeteer.launch({headless: false}); // default is true | |
const page = await browser.newPage(); | |
// 116.451673,39.923054 | |
await page.setGeolocation({latitude: 39.923054, longitude: 130.451673}); | |
// iphone x | |
await page.setViewport({ width: 375, height: 812}); | |
await page.goto('https://h5.ele.me/newretail/p/ehealth/'); | |
page.on('response', async (response) => { | |
if (response.url().startsWith("https://shopping.ele.me/h5/mtop.hasee.channellistservice.getchannellist/1.0")) { | |
console.log('XHR response received'); | |
let data = await response.json(); | |
console.log(data.data.data.shoplist); | |
console.log(data.data.data.shoplist.length); | |
} | |
}); | |
await page.mouse.wheel({ deltaY: 100 }) | |
await page.mouse.wheel({ deltaY: 100 }) | |
// await browser.close(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment