This is a creation in
Article, where the information may have evolved or changed.
Introduction
Beginner Go language, do small things on the arm.
Use the code.google.com/archive/p/mahonia/ bag.
Post code:
Code
PackageMainImport("FMT" "Io/ioutil" "Mahonia" "Net/http" "RegExp" "Strings")funcMain () {//user Cookie varCookiesstring="omvx_2132_saltkey=bq1dwrgn;omvx_2132_auth=95f6c%2bog2r7rfctaansi%2fdkg8khdizeq1pefl79b8nvnvbziyo% 2f8rarfcdqvo8qc2o34nd%2fpv1gdvyinnoujs%2fzy048; " //RegExp. Mustcompile returns a value that can be used for constant definitions //Regexp.compile returns two values, the second value indicates an errorHash_pattern: = RegExp. Mustcompile (' formhash= (. +) ' >.+?</a> ') Resp_pattern: = RegExp. Mustcompile (' <div class= ' C ' >\s*? (.+?) <a href= "') Client: = &http. client{} request, _: = http. Newrequest ("GET","Http://bbs.fishc.com/plugin.php?id=dsu_paulsign:sign",Nil) Request. Header.set ("Cookie", cookie) Res, _: = client. Do (Request) Body_, _: = Ioutil. ReadAll (Res. Body)//FMT. Println (String (body_)) deferRes. Body.close () Formhash: = Hash_pattern. Findstringsubmatch (string(Body_))[1]//FMT. Println (Formhash)Req, _: = http. Newrequest ("POST","Http://bbs.fishc.com/plugin.php?id=dsu_paulsign:sign&operation=qiandao&inajax=1", strings. Newreader ("Qdxq=kx&qdmode=2&todaysay=&fastreply=1&formhash="+formhash)) Req. Header.set ("Content-type","application/x-www-form-urlencoded") Req. Header.set ("Cookie", cookie) Response, _: = client. Do (req) body, _: = Ioutil. ReadAll (response. Body)deferResponse. Body.close () Output: = Mahonia. Newdecoder ("GBK"). Convertstring (string(body)) Result: = Resp_pattern. Findstringsubmatch (Output)[1] FMT. PRINTLN (Result)}
Summary
It's written like Python.
Performance like C