TiktokのREST APIでビデオの情報を取得する

スポンサーリンク

Tiktokの投稿情報が取得できるAPIがあるようなので、

何の役に立つかはわかりませんが試してみました。

TikTok for Developers
Build awesome experiences and powerful tools that inspire creativity and allow users to create, connect, and share with the world

Pythonでデータを表示してみます。

import json
URL = "https://www.tiktok.com/oembed?url=https://www.tiktok.com/@josiah.hughes/video/6745268153930042629"
print(URL)
res=json.loads(requests.get(URL).text)
print(res)
スポンサーリンク

実行結果

#リクエストURL
https://www.tiktok.com/oembed?url=https://www.tiktok.com/@josiah.hughes/video/6745268153930042629
#結果。整形できてなくてすいません {'version': '1.0', 'type': 'video', 'title': 'Which kind of teachers tell the craziest stories? #teachers #stories #pimpleonmylip', 'author_url': 'https://www.tiktok.com/@josiah.hughes', 'author_name': 'Josiah Hughes', 'width': '100%', 'height': '100%', 'html': '<blockquote class="tiktok-embed" cite="https://www.tiktok.com/@josiah.hughes/video/6745268153930042629" data-video-id="6745268153930042629" style="max-width: 605px;min-width: 325px;" > <section> <a target="_blank" title="@josiah.hughes" href="https://www.tiktok.com/@josiah.hughes">@josiah.hughes</a> <p>Which kind of teachers tell the craziest stories? <a title="teachers" target="_blank" href="https://www.tiktok.com/tag/teachers">#teachers</a> <a title="stories" target="_blank" href="https://www.tiktok.com/tag/stories">#stories</a> <a title="pimpleonmylip" target="_blank" href="https://www.tiktok.com/tag/pimpleonmylip">#pimpleonmylip</a></p> <a target="_blank" title="♬ original sound - Josiah Hughes" href="https://www.tiktok.com/music/original-sound-6743979392550128389">♬ original sound - Josiah Hughes</a> </section> </blockquote> <script async src="https://www.tiktok.com/embed.js"></script>', 'thumbnail_width': 540, 'thumbnail_height': 960, 'thumbnail_url': 'https://p16-sign-sg.tiktokcdn.com/obj/tos-maliva-p-0068/c7564af987ac4dc19acf638db3b48390?x-expires=1613786400&x-signature=bhGlPRrOeL9%2FAo2Oh9%2BxMl8eLcQ%3D', 'provider_url': 'https://www.tiktok.com', 'provider_name': 'TikTok'}

ビデオの情報は大体引っ張れているように見えました。

コメント

タイトルとURLをコピーしました