Created
October 22, 2016 07:43
-
-
Save anonymous/f7781da21b44925a36320e61b6f27283 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import sys | |
import requests | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36', | |
} | |
cookies = { | |
'_ts_id': '999999999999999999', | |
} | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
h = requests.get('http://class.ruten.com.tw/user/index00.php?s=nevereverfor', headers=headers, cookies=cookies) | |
#print h.text # 亂碼 | |
#b = h.text.encode('latin-1').decode('big5') # UnicodeDecodeError: 'big5' | |
b = h.text.encode('latin-1').decode('utf-8') | |
print(b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment