Это проблема со ссылкой или моим кодом?Я пытался удалить множество зависимостей requests-html
, но, похоже, результат все тот же.
Как вы думаете, это связано со страницей финансовых новостей?
from requests_html import HTMLSession
session=HTMLSession()
url='https://new.qq.com/ch2/meigu'
r=session.get(url)
content=r.html.render()
ConnectionError Traceback (most recent call last)
<ipython-input-111-b2614c98ba80> in <module>()
1 url='https://new.qq.com/ch2/meigu'
2 r=session.get(url)
----> 3 content=r.html.render()
~/anaconda3/lib/python3.6/site-packages/requests_html.py in render(self, retries, script, wait, scrolldown, sleep, reload, timeout, keep_page)
581 try:
582
--> 583 content, result, page = self.session.loop.run_until_complete(_async_render(url=self.url, script=script, sleep=sleep, wait=wait, content=self.html, reload=reload, scrolldown=scrolldown, timeout=timeout, keep_page=keep_page))
584 except TypeError:
585 pass
~/anaconda3/lib/python3.6/asyncio/base_events.py in run_until_complete(self, future)
465 raise RuntimeError('Event loop stopped before Future completed.')
466
--> 467 return future.result()
468
469 def stop(self):
~/anaconda3/lib/python3.6/site-packages/requests_html.py in _async_render(url, script, scrolldown, sleep, wait, reload, content, timeout, keep_page)
536 async def _async_render(*, url: str, script: str = None, scrolldown, sleep: int, wait: float, reload, content: Optional[str], timeout: Union[float, int], keep_page: bool):
537 try:
--> 538 page = await self.session.browser.newPage()
539
540 # Wait before rendering the page, to prevent timeouts.
~/anaconda3/lib/python3.6/site-packages/pyppeteer/browser.py in newPage(self)
190 async def newPage(self) -> Page:
191 """Make new page on this browser and return its object."""
--> 192 return await self._defaultContext.newPage()
193
194 async def _createPageInContext(self, contextId: Optional[str]) -> Page:
~/anaconda3/lib/python3.6/site-packages/pyppeteer/browser.py in newPage(self)
327 async def newPage(self) -> Page:
328 """Create a new page in the browser context."""
--> 329 return await self._browser._createPageInContext(self._id)
330
331 @property
~/anaconda3/lib/python3.6/site-packages/pyppeteer/browser.py in _createPageInContext(self, contextId)
198
199 targetId = (await self._connection.send(
--> 200 'Target.createTarget', options)).get('targetId')
201 target = self._targets.get(targetId)
202 if target is None:
~/anaconda3/lib/python3.6/site-packages/pyppeteer/connection.py in send(self, method, params)
83 # Detect connection availability from the second transmission
84 if self._lastId and not self._connected:
---> 85 raise ConnectionError('Connection is closed')
86 if params is None:
87 params = dict()
ConnectionError: Соединение закрыто