
import requests
from bs4 import BeautifulSoup
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
data = requests.get('https://movie.naver.com/movie/sdb/rank/rmovie.naver?sel=pnt&date=20210829',headers=headers)
soup = BeautifulSoup(data.text, 'html.parser')
title =soup.select_one('#old_content > table > tbody > tr:nth-child(2) > td.title > div > a')
print(title)
print(title.text)
# 밥정이라는 것을 찾을 때는 .text를 썼으면
print(title['href'])
# /movie/bi/mi/basic.naver?code=186114 이것을 찾을 떄는 .href 가아닌 ['href'] 라고 쓰는 이유가 무엇인가요?
print(title.text)
print(title['href'])
이 2가지에 대해서 강의를 해주셨는데요.
질문은 코드안에 주석으로 표기 했습니다.
감사합니다!
