2017-09-07 1 views
1
from bs4 import BeautifulSoup 
html_doc=''' 
html_doc = """ 
<html><head><title>The Dormouse's story</title></head> 
<body> 
<p class="title"><b>The Dormouse's story</b></p> 

<p class="story">Once upon a time there were three little sisters; and their names were 
<a href="http://example.com/elsie" class="sister" id="link1">Elsie</a>, 
<a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and 
<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>; 
and they lived at the bottom of a well.</p> 

<p class="story">...</p> 
""" 
''' 

soup = BeautifulSoup(html_doc) 

print(soup.prettify()) 

그건 내 코드입니다. 매우 쉽지만 여전히 다음과 같은 오류가 발생합니다.ImportError : 'CharsetMetaAttributeValue'이름을 가져올 수 없습니다.

ImportError: cannot import name 'CharsetMetaAttributeValue'

아무도 말해 줄 수 없습니까?

+1

"from bs4.element import CharsetMetaAttributeValue"을 (를) 오류없이 실행할 수 있습니까? 설치에 문제가 없다면 또한 명명 충돌을 찾으십시오. –

답변

0

이 코드는 제대로 실행되고 bs4 모듈을 다시 설치하면 문제가 해결 될 수 있습니다. 또는 기본적으로 html.parser 대신 lxml 파서를 사용하십시오.

+0

thanks ~ bs4를 다시 설치하여 문제를 해결했습니다. – nikepinapple

관련 문제