Issue
Cannot display correct Chinese word from the python script
Python code
import subprocess
import re
strCmdResult = subprocess.Popen("curl -vvv 'http://xxxx.xxxx.xxxx/xxxx/xxxx.js?r=0071563892276000' -H 'Referer: http://xxx.xxx.xxx'", shell=True, stdout=subprocess.PIPE).stdout.read()
print strCmdResult
Output
rq[56]="1739907^1^11^45^▒▒▒▒▒Ρ▒~▒▒▒▒^27633,24230^▒ڶ▒▒▒ϣ▒▒▒▒Ŭ▒▒ŵ▒▒▒▒^6687323^";
Solution
It seems the file is encoded either the gbk or gb18030 encoding.
Both produce this output for that particular line:
"1732948^1^1^85^洛迪高阿古利 (助攻:A.華倫西亞)^84828^洛迪高阿古利 (助攻:A.瓦伦西亚)^6687325^25000"
The other encodings listed for Chinese fail to decode the data.
You can decode like this:
strCmdResult = subprocess.Popen("curl -vvv 'http://xxx.xxxx.xxx/xxxx/xxx.js?r=0071563892276000' -H 'Referer: http://xxxx.xxx.xxx'", shell=True, stdout=subprocess.PIPE).stdout.read()
decoded = strCmdResult.decode('gbk')
print decoded
Answered By - snakecharmerb
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.