나는 beautifulsoup를 사용하여 HTML을 구문 분석하려고하지만 인라인 스크립트 태그가있는 페이지를 방문 할 때마다 beautifulsoup이 내용을 인코딩하지만 마지막에는 다시 디코딩하지 않습니다. beautifulsoup 만드는 방법 스크립트 태그의 내용을 인코딩 및 디코딩
from bs4 import BeautifulSoup
if __name__ == '__main__':
htmlData = '<html> <head> <script type="text/javascript"> console.log("< < not able to write these & also these >> "); </script> </head> <body> <div> start of div </div> </body> </html>'
soup = BeautifulSoup(htmlData)
#... using BeautifulSoup ...
print(soup.prettify())
내가이 출력하려면 :
<html>
<head>
<script type="text/javascript">
console.log("< < not able to write these & also these >> ");
</script>
</head>
<body>
<div>
start of div
</div>
</body>
</html>
을하지만이 출력 얻을 :
<html>
<head>
<script type="text/javascript">
console.log("< < not able to write these & also these >> ");
</script>
</head>
<body>
<div>
start of div
</div>
</body>
</html>
가 [제출 버그]이 (https://bugs.launchpad.net/beautifulsoup/+bug/950459)에 대한 Beautiful Soup 3. 버그가 Beautiful Soup에서 지속되는 것처럼 보입니다. 4. 버그 신고서 [https://bugs.launchpad.net/beautifulsoup/]를 원할 수 있습니다. –