Answer the question
In order to leave comments, you need to log in
The code doesn't work. What to fix?
I am writing a music parser for myself. The code doesn't work. Displays successful execution, but does not display the required information.
from bs4 import BeautifulSoup
import requests
def parse():
URL = 'https://pixabay.com/music/'
HEADERS = {
'User_Agent': 'Chrome: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36'
}
response = requests.get(URL, headers = HEADERS)
soup = BeautifulSoup(response.content, "html.parser")
items = soup.findAll('article', class_ = 'audio-reactive-track collapsed')
musics = []
for item in items:
musics.append({
'title': item.find('a', class_ = 'name').get_text(strip = True)
})
for music in musics:
print(music['title'])
parse()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question