Created
November 29, 2022 08:41
-
-
Save TakamiChie/eb256d948c736b74f99cd3caf300d023 to your computer and use it in GitHub Desktop.
Google Podcastで自分の聞いてるポッドキャストの一覧を得る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
強引にスクレイピングしているので動かなくなるときもあるかも。 | |
ひとまず以下のコードをGoogle Podcastの登録済みポッドキャスト(https://podcasts.google.com/subscriptions)で開発者コンソールを開いて実行する。 | |
警告は表示されるものの、以下に外部へのデータ送信を行なうコードは一切含まれていないので問題はない。 | |
動かなくなったときのために簡単に解説。まず「ページ先頭のscrolling-carousel要素」を取得する。これが今聞いているポッドキャストの一覧(一番上に出ているやつ)である。 | |
その中のspan配下にそれぞれdivに囲まれたかたちで、各ポッドキャストのサムネイルがある。 | |
このためポッドキャストのサムネイルの中から、ポッドキャストのタイトルだけを抜き取ってテキスト化する。 | |
一つ一つconsole.logで出力すると、全部が別の出力になってしまって面倒くさいので、一旦配列に取り込んで最後にjoinするようにしている。 | |
*/ | |
{let t = [];Array.from(document.querySelector("scrolling-carousel").querySelectorAll(" span[jsname=dr7zhc] div a div:last-child div:first-child")).forEach(v => t.push(v.textContent)); console.log(t.join("\n"));} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment