【问题标题】:Get song name and artist from iTunes top 100 by Python通过 Python 从 iTunes 前 100 名中获取歌曲名称和艺术家
【发布时间】:2018-09-05 04:04:01
【问题描述】:

我对 Python Crawl 有点陌生,只想获取歌曲和艺术家。 Scrapy 肯定会更容易做到这一点,但我想尝试使用 requests 和 bs4。

我知道我需要从这里获取数据:https://itunes.apple.com/us/rss/topsongs/limit=100/json

数据对我来说看起来很复杂,如果有人能指出正确的方向,我将不胜感激。

最好的,

【问题讨论】:

    标签: python-3.x beautifulsoup python-requests web-crawler itunes-store


    【解决方案1】:

    你真的不想用漂亮的汤,因为你有 json 数据。 你只需要请求。

    import requests
    
    url = 'https://itunes.apple.com/us/rss/topsongs/limit=100/json'
    
    response = requests.get(url)
    
    data = response.json()
    
    for artist_dict in data['feed']['entry']:
        artist_name = artist_dict['im:artist']['label']
        song_artist = artist_dict['title']['label']
        print(artist_name)
    

    【讨论】:

    • 您在哪里找到的网址?它没有记录在任何地方,但它可以工作
    猜你喜欢
    • 1970-01-01
    • 2012-09-09
    • 1970-01-01
    • 2016-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-30
    • 2015-03-25
    相关资源
    最近更新 更多