인코딩을 페이지에 맞는 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’
이 글은 ivps.tistory.com 에서 RSS로 가져온 글입니다. 원본보기