Good, I have in Django this configuration in urls.py:
urlpatterns = [
path('', views.index),
]
and in views.py the index function where I pass through the variable a url, I have with requests_html:
from django.http import HttpResponse
from django.core.validators import URLValidator
from requests_html import HTMLSession
from bs4 import BeautifulSoup
from .main import *
def index(request):
url = request.GET.get('url')
# URLValidator...
session = HTMLSession()
resp = session.get(url)
resp.html.render()
resp.html.render()
File "/home/noname/.local/lib/python3.8/site-packages/requests_html.py", line 586, in render
self.browser = self.session.browser # Automatically create a event loop and browser
File "/home/noname/.local/lib/python3.8/site-packages/requests_html.py", line 727, in browser
self.loop = asyncio.get_event_loop()
File "/usr/lib/python3.8/asyncio/events.py", line 639, in get_event_loop
raise RuntimeError('There is no current event loop in thread %r.'
RuntimeError: There is no current event loop in thread 'Thread-1'.
But I get a bug when calling render() and I'm not using threads, any ideas?