PierreMasselot / Frontier-FrenchScientificYoutube

Codes and data of the Frontiers paper describing the French Scientific Youtube ecosystem
GNU General Public License v3.0
5 stars 2 forks source link

HTTP Error 403: Forbidden #2

Closed messier95 closed 2 years ago

messier95 commented 2 years ago

Hi Pierre!

Thanks a lot for sharing these files. The script for extracting the channel information saved me a lot of time during my current research of German science YouTubers.

To create my sample, I also wanted to use the video information script. Unfortunately, it crashes when using it and does not write the "video_list_human_readable.csv" file. APIs were added into the script and the file "all_youtube_ids.txt" was created with one channel ID for testing. For the other script, both API and .txt file worked.

Sadly, as a communication researcher, I am not able to dig deep into the code. Did I miss something, or is the script no longer working? Maybe because YouTube changed the dislike statistics?

Thanks a lot for your time and expertise!

Cheers, Manuel

messier95 commented 2 years ago

Missed to install the pyexcel_ods module, now it works for me. Sorry for the trouble!

PierreMasselot commented 2 years ago

Dear Manuel,

Sorry not to have replied earlier. Happy the issue seems to be sorted.

Pierre

From: messier95 @.> Sent: 08 January 2022 10:32 To: PierreMasselot/Frontier-FrenchScientificYoutube @.> Cc: Subscribed @.***> Subject: Re: [PierreMasselot/Frontier-FrenchScientificYoutube] Script to extract video information crashes without writing the output file (Issue #2)

Missed to install the pyexcel_ods module, now it works for me. Sorry for the trouble!

— Reply to this email directly, view it on GitHubhttps://github.com/PierreMasselot/Frontier-FrenchScientificYoutube/issues/2#issuecomment-1007950808, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKJ7CIHLD5QAOYETS57JGETUVAHDZANCNFSM5LPLHIDQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

messier95 commented 2 years ago

Hello again Pierre,

thanks for your reply.

The mentioned issue was sorted, but after scraping around ~2000 Videos from 15 channels, I encountered the "urllib.error.HTTPError: HTTP Error 403: Forbidden" Error.

I tried to resolve the issue by restricting the API to the YouTube Data API v3 and adding the following header information. Unfortunately, neither solved the error.

...
site= 'https://www.googleapis.com/youtube/v3/searchpart=snippet&channelId='+channel_id+'&type=video&key='+api_key+'&maxResults=50&order=date'+next_page
hdr = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
       'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
       'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
       'Accept-Encoding': 'none',
       'Accept-Language': 'en-US,en;q=0.8',
       'Connection': 'keep-alive'}
req = Request(site, headers=hdr)
page = urlopen(req)
contents = page.read()
json_data = json.loads(contents)
...

My next step is to try to construct a service instance with my client.secret.json file. For now, I have not been able to successfully do that.

Are you familiar with this error? Do you know any workaround for it?

Thanks a lot in advance and have a great day! Manuel

stephanedebove commented 2 years ago

Hi messier95, I worked with Pierre on this project. The first thing that comes to my mind is that you’ve hit your quota of daily requests. You’ll find this information in your google API account. If that’s the case you’ll have to query a little bit each day, or ask google to increase your quota (there’s a form for that I think in your account).

messier95 commented 2 years ago

Hi Stephane,

thanks a lot for your reply and your help. You are completely right, I exceeded the limited quota, which led to the issue. Thanks also for the info on how to increase it, I just submitted the form.

Have a great day! Manuel