python-webdriver和asyncio [英] python - webdriver and asyncio

查看:63
本文介绍了python-webdriver和asyncio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以先为每个任务打开浏览器,然后再加载链接?这段代码会引发错误

Is it possible open browser for each task firstly, and load links after that ? This code raises an error

import asyncio
from selenium import webdriver

async def get_html(url):
    driver = await webdriver.Chrome()
    response = await driver.get(url)

TypeError:对象WebDriver不能在等待"表达式中使用

TypeError: object WebDriver can't be used in 'await' expression

推荐答案

在以下位置讨论了该问题:https://github.com/SeleniumHQ/selenium/issues/3399

The problem was discussed at: https://github.com/SeleniumHQ/selenium/issues/3399

如果您要使用异步网络驱动程序,则可以使用两个库:

If you want to have async webdrivers, there are two libraries you can use:

这篇关于python-webdriver和asyncio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆