3

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?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Ismael
  • 99
  • 1
  • 8

0 Answers0