requests_html library error=Cannot use HTMLSession within an existing event loop. Use AsyncHTMLSession instead

Viewed 1151

I was trying to use the library requests_html in my jupyter notebook when I step with the error of:

Cannot use HTMLSession within an existing event loop. Use AsyncHTMLSession instead.

I search for solutions and found this one:

import nest_asyncio
nest_asyncio.apply()

But when I apply it to mi code:

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

The error keeps going. Do you know any solution for this problem?

0 Answers
Related