하얀설표 블로그




해결)No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml").





( 수정됨)


에러 예시

import bs4
html = '<p>하얀설표 블로그</p>'
soup = bs4.BeautifulSoup(html)
print(soup)

>> c:\seolpyo\example.py:3: GuessedAtParserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). 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.

The code that caused this warning is on line 3 of the file c:\seolpyo\example.py. To get rid of this warning, pass the additional argument 'features="lxml"' to the BeautifulSoup constructor.

  soup = bs4.BeautifulSoup(html)
<html><body><p>하얀설표 블로그</p></body></html>

해결방법

bs4.BeautifulSoup 명령시 markup 인수를 전달한다.

설명

대부분 bs4.BeautifulSoup 명령에서 markup 인수를 전달하지 않아 출력되는 경고문구다.
파이썬 bs4 모듈은 markup 인수를 전달받지 못한 경우 자체적으로 판단하는 기능을 포함하고 있지만, 완벽하진 않다.

가능하면 정확한 변환을 위해 markup 인수를 전달하자.

beautifulsoup4에서 지원하는 markup은 html.parser, lxml, lxml-xml, xml, html5lib이 있다.
그 외 자세한 내용은 공식 문서에서 확인이 가능하다.


공감 : 0







white.seolpyo.com