requests-html icon indicating copy to clipboard operation
requests-html copied to clipboard

render() got an unexpected keyword argument 'cookies'

Open JustRin opened this issue 4 years ago • 10 comments

ubuntu 20.04

from  requests_html import HTMLSession

session = HTMLSession()
url = 'mysite.com'
r = session.get(url)
cookie=[{'name': 'value'},{'name':'value'}]
r.html.render(timeout=20, cookies = cookie)

Traceback (most recent call last): File "bot.py", line 10, in r.html.render(cookies=cookie) TypeError: render() got an unexpected keyword argument 'cookies'

how to set a cookies for work with web site?

JustRin avatar Nov 18 '20 21:11 JustRin

Same problem here

Tiebe avatar Nov 21 '20 13:11 Tiebe

need help, hit with multiple settings like send_cookies_session , cookies and etc..

FlashLim avatar Dec 12 '20 16:12 FlashLim

I realized the release version 0.10 is released by Sep 2019, but the latest commit is May 2020. Anyone can help to release the new version?

FlashLim avatar Dec 12 '20 17:12 FlashLim

same issue here

PyLit avatar May 16 '21 20:05 PyLit

same here

titzko avatar Jul 18 '21 08:07 titzko

Same here

a14stoner avatar Jul 19 '21 16:07 a14stoner

I solved this error with installing requests-html==0.10.0

Before there was an old version of requests-html under /usr/local/lib/python3.7/dist-packages/requests_html.py

Now cookies, send_cookies_session is available.

a14stoner avatar Jul 20 '21 06:07 a14stoner

I solved the issue. The latest code is not published. You need to uninstall your current package and install the Github master branch one. FYI, you could install this way pip install git+https://github.com/psf/requests-html.git

jacksong18 avatar Nov 03 '21 08:11 jacksong18

I solved the issue. The latest code is not published. You need to uninstall your current package and install the Github master branch one. FYI, you could install this way pip install git+https://github.com/psf/requests-html.git

this comment solved my problem of no "cookies" param!

but a problem produced: requests_html.MaxRetries: Unable to render the page. Try increasing timeout i have set timeout=20000, still not enough?

any one encouted this?

hotdog5225 avatar Nov 05 '21 08:11 hotdog5225

I solved the issue. The latest code is not published. You need to uninstall your current package and install the Github master branch one. FYI, you could install this way pip install git+https://github.com/psf/requests-html.git

this comment solved my problem of no "cookies" param!

but a problem produced: requests_html.MaxRetries: Unable to render the page. Try increasing timeout i have set timeout=20000, still not enough?

any one encouted this?

Not sure whether this is still needed, but for future reference: For me, this issue was caused by providing the cookies like mentioned above , but instead it wanted the dicts to be given as follows: r.html.render(cookies=[{'name': 'cookie_name', 'value': 'cookie_value', 'domain': 'cookie_domain'}]) Note that at least one of url and domain needs to be specified.

Figured this out by printing the TypeError exception which is ignored in render() in requests_html.py on line 665 So if it doesn't fix your problem, then this exception might help you further

for i in range(retries):
    if not content:
        try:
            content, result, page = self.session.loop.run_until_complete(...)
        except TypeError as e:
            print(e)
    else:
        break

Stijn-K avatar Nov 30 '21 16:11 Stijn-K