ConnectionError: соединение закрывается при использовании. html .render () - PullRequest
0 голосов
/ 07 мая 2020

Я использую requests_ html библиотеку.

Вот код, который я использовал:

>>> from requests_html import HTMLSession
>>> session = HTMLSession()
>>> r = session.get('https://leetcode.com/contest/')
>>> r.html.render()

Когда is call. html .render () function Я получаю эту ошибку:

ConnectionError: Connection is closed

Может ли кто-нибудь сказать мне, почему возникает эта ошибка и как решить?

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sudesh/anaconda3/envs/cfc/lib/python3.8/site-packages/requests_html.py", line 598, in rende
r

    content, result, page = self.session.loop.run_until_complete(self._async_render(url=self.url, script=
script, sleep=sleep, wait=wait, content=self.html, reload=reload, scrolldown=scrolldown, timeout=timeout,
 keep_page=keep_page))
  File "/home/sudesh/anaconda3/envs/cfc/lib/python3.8/asyncio/base_events.py", line 616, in run_until_com
plete
    return future.result()
  File "/home/sudesh/anaconda3/envs/cfc/lib/python3.8/site-packages/requests_html.py", line 505, in _asyn
c_render
    page = await self.browser.newPage()
  File "/home/sudesh/anaconda3/envs/cfc/lib/python3.8/site-packages/pyppeteer/browser.py", line 192, in n
ewPage
    return await self._defaultContext.newPage()
  File "/home/sudesh/anaconda3/envs/cfc/lib/python3.8/site-packages/pyppeteer/browser.py", line 329, in n
ewPage
    return await self._browser._createPageInContext(self._id)
  File "/home/sudesh/anaconda3/envs/cfc/lib/python3.8/site-packages/pyppeteer/browser.py", line 199, in _
createPageInContext
    targetId = (await self._connection.send(
  File "/home/sudesh/anaconda3/envs/cfc/lib/python3.8/site-packages/pyppeteer/connection.py", line 85, in
 send
    raise ConnectionError('Connection is closed')
ConnectionError: Connection is closed
...