点此免费加入Python网络爬虫学习交流QQ群:428518750

1、启动浏览器时,指定每个操作延迟的秒数

playwrigth.chromium.launch(headless=False,slow_mo=3000)

启动浏览器后,每个操作停3秒。

2、可以重载等待的事件,比如等待直到触发networkidle

page.goto(“http://www.baidu.com”, wait_until=”networkidle”)

3、等待指定元素加载完成

page.locator(“title”).wait_for()

等待,直到title元素加载完成

4、从浏览器方便的复制出selector、XPath

5、定位iframe内部的元素

page.frame_locator('//*[@id="ayui-layer-iframe1"]').\
    locator('//*[@id="filePicker"]/div[2]/input').\
    set_input_files(r"F:\111.jpg")

page.frame_locatar(' //*[@id="layui-layer-iframe1"]').\
    locator('//div[@class="saveBtn"]').click()

点此免费加入Python网络爬虫学习交流QQ群:428518750

picture loss