Untitled

код для пидорасв
mail@pastecode.io avatar
unknown
python
2 years ago
605 B
2
Indexable
Never
import requests
import json
from bs4 import BeautifulSoup


url = "https://music.yandex.ru/chart"
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')

chart = {}
for i, item in enumerate(soup.find_all("div", {"class": "chart__item"}), 1):
    artist = item.find("div", {"class": "d-track__name"})
    print(artist)
    track = item.find("div", {"class": "chart__item-text"}).find("a", {"class": "chart__item-title"}).text
    chart[i] = (artist, track)

with open('yandex_music_chart.json', 'w', encoding='utf-8') as f:
    json.dump(chart, f, ensure_ascii=False, indent=4)