M
M
Morrdor2021-10-22 11:25:15
Python
Morrdor, 2021-10-22 11:25:15

How to parse apple music?

0


def applemusic():
    appleMusicUrl = f"https://music.apple.com/ua/search?term={songName}"
    appleMusicUrl = appleMusicUrl.replace(" ", "%20")
    response = requests.get(appleMusicUrl)
    html = response.text
    soup = BeautifulSoup(html, "html.parser")
    songTab = soup.select_one('div[class="search__top-results"]').text
    # nameofSong = songTab.select_one('li:first-child')
    # artist = songTab.select_one('li:nth-child(2)')
    file.write("Apple Music songs from Finder: \n" + songTab + "\n===========\n")
    print(songTab)

applemusic()


Wrote other parsers in the same way. Everything worked

Now it says that the NoneType object does not have a text attribute

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question