Python/Crawling
[Crawling] 멜론 페이지 응답받기
퓨어맨
2022. 5. 19. 08:59
h = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36'}
url = 'https://www.melon.com/'
res = req.get(url, headers = h)
res
soup = bs(res.text, 'lxml')
soup
result = soup.select('span.menu_bg')
for i in result:
print(i.text)
url = 'https://www.melon.com/chart/index.htm'
res = req.get(url, headers = h)
res
soup = bs (res.text, 'lxml')
soup
title = soup.select('.rank01')
for i in title:
print(i.text.strip()) # strip() 문자열 \n, \t 없애줌
url = 'https://www.melon.com/chart/index.htm'
res = req.get(url, headers = h)
soup = bs (res.text, 'lxml')
singer = soup.select('span.checkEllipsis> a:nth-child(1)')
for i in singer:
print(i.text)