Created
May 4, 2023 08:14
-
-
Save TakamiChie/18553c871aa6065d80c19de7c99b6c8f to your computer and use it in GitHub Desktop.
SBCast.のフィードタイトルを取得する
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
import xmltodict | |
import requests | |
# デバッグ用 | |
def print_keys(obj, prefix=''): | |
if isinstance(obj, dict): | |
for k, v in obj.items(): | |
print_keys(v, prefix + k + '.') | |
elif isinstance(obj, list): | |
for i, item in enumerate(obj): | |
print_keys(item, prefix + str(i) + '.') | |
else: | |
print(prefix[:-1]) | |
response = requests.get('https://sbc.yokohama/category/sbcast/feed') | |
xml_data = response.content | |
rss = xmltodict.parse(xml_data) | |
for item in reversed(rss["rss"]["channel"]["item"]): | |
print(f" * {item['title']}:") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://colab.research.google.com/drive/1uUy_3rhhv5vra0aDc7KKOMtyww2xYn54?usp=sharing