This is a creation in Article, where the information may have evolved or changed.
GO, Python can not be done in more than 10 minutes, easy language, may be a few minutes to finish, domestic easy language feel fast ah.
Type loginsave struct {Returnck []*http. Cookie}type Oschina Interface {login (user string, pass string) string save (title string, content String) String}func Main () {User: = "xxxxxx@qq.com"//Account Pass: = "xxxxxxxxxx"//password user = strings. Replace (User, "@", "%40", 1) pass = (Shacryto (pass)) Lo: = Loginsave{[]*http. cookie{}} lo.login (user, pass) lo.save ("Testall", "Look at Me")}func Shacryto (src String) string {h: = SHA1. New () H.write ([]byte (SRC)) return hex. Encodetostring (H.sum (nil))}func (lo *loginsave) login (user, pass String) string {client: = &http. client{} req, err: = http. Newrequest ("POST", "Https://www.oschina.net/action/user/hash_login", strings. Newreader ("email=" +user+ "&pwd=" +pass+ "&verifycode=&save_login=1")) if err! = Nil {//Handle error} Req. Header.set ("Content-type", "application/x-www-form-urlencoded") resp, err: = client. Do (req) defer resp. Body.close () body, err: = Ioutil. ReadAll (resp. Body) If err! = Nil{//Handle error} Lo.returnck = resp. Cookies () fmt. Println (String (body)) fmt. Println ("==================") return "1"}func (sa *loginsave) Save (title string, content String) string {client: = &A Mp;http. client{} fmt. Println (Sa.returnck) req, err: = http. Newrequest ("POST", "Https://my.oschina.net/action/blog/save", strings. Newreader ("draft=590308&user_code=xowizssfmaowkbf0oldqjnujch2vdgufhcgc55py&id=&catalog=286094& Title= "+title+" &content_type=4&tags=&classification=428640&type=1&origin_url=&privacy= 1&deny_comment=1&as_top=0&isrecommend=on&abstracts=&content=%3cp%3e "+content+"%3C%2Fp%3E%0 a&temp=1490495330601 ")) if err! = Nil {//Handle error} FMT. Println (Sa.returnck) req. Header.set ("Content-type", "application/x-www-form-urlencoded") for _, I: = Range Sa.returnck {req. Addcookie (i)} resp, err: = client. Do (req) defer resp. Body.close () body, err: = Ioutil. ReadAll (resp. BodyIf err! = Nil {//Handle error} FMT. Println (resp. Cookies ()) fmt. Println (String) return "1"}
Python's words, did not write, because I do this post program to vomit, estimated to do hundreds of.