requests-html
requests-html copied to clipboard
AttributeError: '_asyncio.Future' object has no attribute 'html'
Windows 10 Pro 10.0.19041 Python 3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)] PyCharm 2020.3.2 (Community Edition) Build #PC-203.6682.179, built on December 30, 2020 Runtime version: 11.0.9.1+11-b1145.63 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
pyppeteer v0.2.5 requests-html v0.10.0 requests v2.25.1
from requests_html import AsyncHTMLSession asess = AsyncHTMLSession() r = asess.get(url) r.html.arender()
AttributeError: '_asyncio.Future' object has no attribute 'html'
@nhwalkman
you forgot to await r.html.arender()
but incase your still having problems I made this to help you out
if you were using asynchronous programming do this
from requests-html import AsyncHTMLSession
async def get_website(url: str):
asession = AsyncHTMLSession()
r = await asession.get(url)
await r.html.arender(sleep = 10) # sleeping is optional but do it just in case
html = r.html.raw_html # this can be returned as your result
await asession.close() # this part is important otherwise the Unwanted Kill.Chrome Error can Occur
return html
Here's the non async way to do it
from requests-html import HTMLSession
def get_website(url:str):
session = HTMLSession()
r = session.get(url)
r.html.render()
html = r.html.raw_html # this can be returned as your result
session.close()
I hope I was able to solve your or anyone else's problems