티스토리 뷰

bs4는 파이썬의 기본 파서도 지원하지만 외부의 서드파티 파서도 지원한다. 

lxml, html5lib 등의 파서를 지원한다. 


다음의 오류는 파서를 지정하지 않아서 발생하는 오류이다. 

파이썬 기본 파서를 사용하려면, "html.parser"를 지정하면 된다. 


lxml 을 이용하기 위해서는 pip를 이용하여 설치를 해야 한다. 

설치는 "pip install lxml" 으로 하면된다. 


UserWarning: No parser was explicitly specified, so I'm using the best

available HTML parser for this system ("html.parser"). This usually isn't a

problem, but if you run this code on another system, or in a different

virtual environment, it may use a different parser and behave differently.


To get rid of this warning, change this:


 BeautifulSoup([your markup])


to this:


 BeautifulSoup([your markup], "html.parser")


bs = BeautifulSoup(r.text, "html.parser")

bs = BeautifulSoup(r.text, "lxml")



파서 인스톨 - https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/02   »
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
글 보관함