requests_html library error=无法在现有事件循环中使用 HTMLSession改用 AsyncHTMLSession

问题描述

当我遇到以下错误时,我试图在我的 jupyter 笔记本中使用库 requests_html:

不能在现有事件循环中使用 HTMLSession。改用 AsyncHTMLSession。

搜索解决方案并找到了这个:

import nest_asyncio
nest_asyncio.apply()

但是当我将其应用于 mi 代码时:

from requests_html import HTMLSession
import nest_asyncio

nest_asyncio.apply()

session = HTMLSession()

r = session.get('http://python-requests.org')

r.html.render()

print(r.html.search('Python 2 will retire in only {months} months!')) # None

错误不断。 你知道这个问题的解决方案吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)