-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbs4_melon.py
More file actions
29 lines (22 loc) · 724 Bytes
/
Copy pathbs4_melon.py
File metadata and controls
29 lines (22 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from bs4 import BeautifulSoup
import requests
header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (like Gecko) Chrome/63.0.3239.132 Safari/537.36'} #headers= 부터 여기까지 한 줄임
url = 'https://www.melon.com/chart/'
html = requests.get(url, headers = header).text
soup = BeautifulSoup(html, 'html.parser')
titles = soup.find_all('div', {'class':'ellipsis rank01'})
artists = soup.find_all('span', 'checkEllipsis')
print(len(artists))
for a in artists:
print(a.get_text())
print(len(artists))
'''
title = []
for t in titles:
title.append(t)
artist = []
for a in artists:
artist.append(a)
for i in range(100):
print(str(i+1)+"위: "+title[i]+"- "+artist[i])
'''