编程语言
首页 > 编程语言> > python pyppeteer 强制点击 Jeval

python pyppeteer 强制点击 Jeval

作者:互联网

import pyppeteer
import asyncio


async def main():
    browser = await pyppeteer.launch(headless=False, userDataDir='./userdata', args=['--disable-infobars'])
    page = await browser.newPage()
    await page.setViewport({'width': 1366, 'height': 768})
    await page.evaluateOnNewDocument('Object.defineProperty(navigator,"webdriver",{get:()=>undefined})')
    await page.goto('https://www.bilibili.com')

    await page.waitForSelector('.unlogin-avatar')
    await page.click('.unlogin-avatar')

    await page.waitForSelector('.login-btn')
    # 强制点击, 用一般的方法无法点击
    await page.Jeval('.login-btn', 'node => node.click()')


    await asyncio.sleep(100)
    

if __name__ == '__main__':
    asyncio.get_event_loop().run_until_complete(main())

标签:__,await,python,pyppeteer,Jeval,main,page,asyncio
来源: https://blog.csdn.net/weixin_55399173/article/details/121350270