엔지니어
python3 beautifulsoup 한글 깨짐
Nj
2017. 2. 16. 00:15
구글링 해서 찾은 결과로는
대부분의 블로그에서 3번쨰 인자 값을 추가하라고 되어있다.
soup = BeautifulSoup(r.content, 'html.parser', from_encoding='utf-8')
허나 하나도 안된다.
영어로 다시 검색해서 찾아보니..
검색 키워드 : python3 beautifulsoup encoding utf-8
찾았다..
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
from requests import get
def test():
url = 'http://xxxxxxxxxxxx'
r = get(url)
soup = BeautifulSoup(r.content.decode('euc-kr','replace'))
print(soup)
replace, ignore를 사용하라는 네이버 블로그의 글이
간접적으로 도움이 되었음.
반응형