Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wget.sh里请求 login.mobile.reg2t.sandai.net 的返回结里带中文,导致grep部分失效 #19

Open
oscar-c opened this issue Oct 17, 2015 · 5 comments

Comments

@oscar-c
Copy link

oscar-c commented Oct 17, 2015

这个的结果大概是这样的

{
   "errorCode" : 0,
   "userNewNo" : [迅雷ID],
   "jumpKey" : "[blah bhal]",
   "payName" : "商务合作付费",
   "expireDate" : "[VIP过期时间]",
   "sessionID" : "[sessionID]",
   "userName" : "[用户名]",
   "cmdID" : 2,
   "platformVersion" : 1,
   "isVip" : 1,
   "vasType" : 4,
   "account" : 138305,
   "userID" : [数字],
   "payId" : 801,
   "isCompressed" : 0,
   "sequenceNo" : 1000001,
   "protocolVersion" : 101,
   "nickName" : "[昵称]"
}

就是那个payName,是GB2312编码的,会导致grep不能获得 userID。sessionID 因为在中文之前,所以还没什么问题。

我是OS X的bash环境, LANG=en_US.UTF-8 ,可能和其它的测试环境不一样。

@oscar-c oscar-c changed the title 请求 login.mobile.reg2t.sandai.net 的返回结里带中文,导致grep部分失效 wget.sh里请求 login.mobile.reg2t.sandai.net 的返回结里带中文,导致grep部分失效 Oct 17, 2015
@fffonion
Copy link
Owner

qq 20151017024538
不会吧 现在的正则echo $ret|grep -oE "userID..[0-9]{9}"匹配不到中文啊

@oscar-c
Copy link
Author

oscar-c commented Oct 17, 2015

我觉得是不是匹配的问题,而是grep在扫过“商务合作付费”之后就坏掉了,所以每次都没能获得有效的userID。

我加了一个 echo $ret 在请求 login.mobile.reg2t.sandai.net 那一行的后面,然后payName那一栏是是这样的 "payName":"???????????"

是编码的原因吧。

我试着在 $HTTP_REQ https://login.mobile.reg2t.sandai.net:443/ ..... 后面加上了一个 | iconv -f GB2312"echo $ret输出的 payName那一栏里就能正经输出“商务合作付费”的中文了,grep也能找到userID了

@fffonion
Copy link
Owner

哦我懂了grep把它当成binary file了……
gnu grep可以加上-a解决
osx版的grep貌似加了-a也没啥卵用……

@yaodwwy
Copy link

yaodwwy commented Oct 18, 2015

我学的是java,对linux还刚刚入门,拿这个研究刚刚好,哈哈

@oscar-c
Copy link
Author

oscar-c commented Oct 18, 2015

奇怪的是貌似就只有登录时的回复候需要iconv来转换一下,
upgrade的时候的回复虽然也返回中文,但是却没有这种问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants