I URLLIB과 BeautifulSoup로 다음 코드가 있습니다URL 개방 인코딩
getSite = urllib.urlopen(pageName) # open current site
getSitesoup = BeautifulSoup(getSite.read()) # reading the site content
print getSitesoup.originalEncoding
for value in getSitesoup.find_all('link'): # extract all <a> tags
defLinks.append(value.get('href'))
그것의 결과 :
/usr/lib/python2.6/site-packages/bs4/dammit.py:231: UnicodeWarning: Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.
"Some characters could not be decoded, and were "
그리고 난이 사이트를 읽으려고 할 때 내가 얻을 :
�7�e����0*"I߷�G�H����F������9-������;��E�YÞBs���������㔶?�4i���)�����^W�����`w�Ke��%��*9�.'OQB���V��@�����]���(P��^��q�$�S5���tT*�Z
을
사이트는 = UTF-8 ", 또한 디코드 ("UTF-16 ")을 시도 나 복호화있어 문자셋했다 오류 – badc0re
링크를 공유 할 수 있습니까? 사이트가 잘못 구성되어있을 수 있으므로 인코딩을 추측해야 할 수도 있습니다. –
http://www.kafepauza.mk/ 여기 링크가 있습니다 – badc0re