웹에서 파싱한 데이터 등 한글을 인식해야 할때 참 골치아프다.
unicode를 사용하면 간단하다.
#-*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import requests
#print unicode("안녕")
# l = [165, 178]
for x in range(1, 5000):
url = 'http://www.hanatour.com/asp/booking/schedule/tour/tour_tour_comment.asp?pkg_code=JKP500190104TWW&pkg_mst_code=JKP500&value_travel_type=&value_req_page='+str(x)
page = unicode(requests.get(url).text)
#print page
if unicode("홍길동") in page:
print x, "found !"
print x
'Programming > python' 카테고리의 다른 글
| matplotlib에서 show() 할 때 빈 화면 해결 (7) | 2019.07.11 |
|---|---|
| bs4를 이용한 웹 크롤링 (파싱) (0) | 2019.01.14 |
| python 정수형 signed, unsigned 변환 (0) | 2018.12.18 |
| python md5, sha256 (0) | 2018.08.19 |
| requests 모듈 (0) | 2017.01.11 |