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())