Skip to content
Advertisement

Is it possible to call a function inside another function in Python? (Web-Scraping problem)

I’m working on a web-scraping task and I can already collect the data in a very rudimentary way.

Basically, I need a function to collect a list of songs and artists from the Allmusic.com and then add the data in df. In this example, I use this link: https://www.allmusic.com/mood/tender-xa0000001119/songs

So far, I managed to accomplish most of the objective, however, I had to perform two different functions (def get_song() and def get_performer()).

I would like, if possible, an alternative to join these two functions.

The codes used are below:

JavaScript

Advertisement

Answer

To get titles/performer you can use next example:

JavaScript

Prints:

JavaScript

and saves data.csv (screenshot from LibreOffice):

enter image description here

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement