実現したいこと
APIで取得したデータをHTMLにブラウザ表示したい
発生している問題・分からないこと
APIで曲名と画像のデータを取得しました。このデータを実行するとHTMLに反映させるということを行いたいと考えています。
該当のソースコード
import spotipy from spotipy.oauth2 import SpotifyClientCredentials import webbrowser uri = 'spotify:artist:6y5xgoSWc4kL9F16ZQO1lv' client_id = "1ee3b96d8d6643a1adf0b579918c3152" client_secret = "b985ff313c694b32ba21bc288bb2d7cf" ccm = SpotifyClientCredentials(client_id, client_secret) spotify = spotipy.Spotify(client_credentials_manager = ccm) results = spotify.artist_top_tracks(uri) for track in results['tracks'][:10]: print('track : ' + track['name']) print('audio : ' + track['preview_url']) print('cover art: ' + track['album']['images'][0]['url']) print() html="<html><head></head><body><hi></h1></body></html>" with open("index.html","w") as f: f.write(html) webbrowser.open("index.html")
試したこと・調べたこと
上記の詳細・結果
pythonを扱うのが初めてであり、ネットで調べながら勉強していますが個人ではわからない範囲のため質問させていただきました。
補足
特になし

0 コメント