인코딩을 페이지에 맞는 euc-kr 또는 utf-8 로 바꿔주면 됩니다.
[root@ivps ~]# python
Python 2.7.5 (default, Apr 9 2019, 14:30:50)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> rs = req.session()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'req' is not defined
>>> rs = requests.session()
>>> post = rs.get('https://ivps.tistory.com/')
>>> print post.text
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>TISTORY</title>
<link rel="stylesheet" type="text/css" href="//t1.daumcdn.net/tistory_admin/www/style/top/font.css">
<link rel="stylesheet" type="text/css" href="//t1.daumcdn.net/tistory_admin/www/style/top/error.css">
</head>
<body>
<div id="kakaoIndex">
<a href="#kakaoBody">본문 ���기</a>
<a href="#kakaoGnb">�� ���기</a>
</div>
>>> post.encoding
'ISO-8859-1'
>>> post.encoding = 'utf-8'
>>> print post.text
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>TISTORY</title>
<link rel="stylesheet" type="text/css" href="//t1.daumcdn.net/tistory_admin/www/style/top/font.css">
<link rel="stylesheet" type="text/css" href="//t1.daumcdn.net/tistory_admin/www/style/top/error.css">
</head>
<body>
<div id="kakaoIndex">
<a href="#kakaoBody">본문 바로가기</a>
<a href="#kakaoGnb">메뉴 바로가기</a>
</div>
post.encoding = 'utf-8'
'Python' 카테고리의 다른 글
[Python] 웹에서 GET POST 변수 가져오는 방법 (0) | 2019.08.20 |
---|---|
[Python] urlopen ImportError (0) | 2019.08.19 |
[CentOS] Python PIP 설치 (0) | 2019.08.19 |
[Python] 이미지 파일의 MIME TYPE 알아내는 방법 (0) | 2018.12.26 |
[CentOS] 7.x Apache + Python 연동 방법 (0) | 2018.12.21 |