Skip to content
Advertisement

Accept cookies consent from Youtube

I’m trying to retrieve a list of Youtube videos from a Youtube channel, say “https://www.youtube.com/user/YouTube/videos”, to get the nth first videos (thanks to the key = "videoId"). It used to work like a charm until a few days ago, when it started to ask for my consent.

I tried many things on SO with no luck, I still see the message asking me to accept the cookies in order to see the videos.

JavaScript

It still returns the same message asking my consent for cookies (in html obviously, this is a picture of what I get when opening Youtube in a private session):

YT Consent

My idea was then to replicate the Consent cookie and sent it back to be able to access the page content.

Any idea of what I’m doing wrong? The idea is not to use the Youtube API but only request/BeautifulSoup if needed.

Advertisement

Answer

You need to delete first response cookies. I’m not sure how to do that in requests.session, but any of the following works for me.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement