1) BeautifulSoup 객체 구조
html → <html> .... </html>
head → <head> .... </head>
title → <title>A Useful Page</title>
body → <body> ..... </body>
h1 →<h1>An Interesting Title</h1>
div → <div> .... </div>
<h1> 태그는 BeautifulSoup 객체구조 (html -> body -> h1)에서 두 단계만큼 중첨되어 있음 하지만 객체에서 가져올 때는 h1태그를 직접 가져옴
예) bs.h1 = (
bs.html.body.h1 (다 같은 말)
bs.body.h1 (다 같은 말)
bs.html.h1 (다 같은 말)
)
2) BeautifulSoup 객체 생성
bs = BeautifulSoup(html.read(), 'html.parser)
BeautifulSoup( 매개변수1 , 매개변수2 )
첫번째 매개변수: 객체의 근간이 되는 HTML 텍스트
두번째 매개변수: BeautifulSoup가 객체를 만들 때 쓰는 구문 분석기