
다름이 아니라 아래 다른분께서 3주차 숙제 크롤링하기를
저와 같은 고민을 올리셨던 분이 계셨는데요
강의에서 배운대로 코드를 실행하면
<<<<<<<<<<<<<<<실행값>>>>>>>>>>>>>>>>>>
C:\Users\USER\Desktop\sparta\pythonprac\venv\Scripts\python.exe C:/Users/USER/Desktop/sparta/pythonprac/genie.py
1 바라만 본다 MSG워너비 (M.O.M)
2 Next Level aespa
3 신호등 이무진
4 Weekend 태연 (TAEYEON)
5 치맛바람 (Chi Mat Ba Ram) 브레이브걸스 (Brave girls)
6 Butter 방탄소년단
7 나를 아는 사람 MSG워너비 (정상동기)
8 Permission to Dance 방탄소년단
9 비 오는 날 듣기 좋은 노래 (Feat. Colde) 에픽하이 (EPIK HIGH)
10 헤픈 우연 헤이즈 (Heize)
11 하루만 더 빅마마 (Big Mama)
12 비와 당신 이무진
13 Alcohol-Free TWICE (트와이스)
14 롤린 (Rollin') 브레이브걸스 (Brave girls)
15 19금
Peaches (Feat. Daniel Caesar & Giveon) Justin Bieber
-------
15위 곡에서 이런 문제가 발생을 하여 그 게시글에 달린 튜터님의 답변을 보니까
for track in tracks:
a = track.select_one('td.info > a.title.ellipsis')
if a is not None:
title = a.text.strip()
rank = track.select_one('td.number').text[0:2].strip()
artist = track.select_one('a.artist.ellipsis').text.strip()
if rank == '15':
title = title.replace(' ', '').replace('\n', '')
print(rank, title, artist)
이런식으로 코드를 써서 저도 도움을 받았습니다 근데 저 코드에서
if rank == '15':
title = title.replace(' ', '').replace('\n', '')
이 코드를 사용함으로 앞에 여백과 '19금' 이게 없어진게 궁금합니다!
