第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

博客轉(zhuǎn)發(fā)小工具2

標(biāo)簽:
前端工具

下一篇:博客小工具3

昨天发了一个博客转发小工具有朋友说“能一键转发到各主流媒体站上就更好了”。一开始我以为会能难,需要登录啊还有cookie的管理啊模拟post请求啊,乱七八糟一大堆。心想算啦,太累人,还不一定搞得定。后来心里总想着有没有什么简单的办法,就在网上查资料。最后皇天不负有心人让我找到了HttpClient。

ok,接着昨天的来。昨天的只能获取别人文章的内容复制到粘贴板。今天让它能一键发布。

首先需要解决的问题就是登录问题,不然可能是不能发布的。

登录博客园的代码

复制代码

 1         /// <summary> 2         /// 登录博客园 3         /// </summary> 4         /// <param name="username"></param> 5         /// <param name="password"></param> 6         /// <returns></returns> 7         public bool LoginCnblogs(string username = "", string password = "") 8         { 9             httpClient = new HttpClient();10             httpClient.MaxResponseContentBufferSize = 256000;11             httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36");12             String url = "http://passport.cnblogs.com/login.aspx";13             HttpResponseMessage response = httpClient.GetAsync(new Uri(url)).Result;14             String result = response.Content.ReadAsStringAsync().Result;15 16             String __EVENTVALIDATION = new Regex("id=\"__EVENTVALIDATION\" value=\"(.*?)\"").Match(result).Groups[1].Value;17             String __VIEWSTATE = new Regex("id=\"__VIEWSTATE\" value=\"(.*?)\"").Match(result).Groups[1].Value;18             String LBD_VCID_c_login_logincaptcha = new Regex("id=\"LBD_VCID_c_login_logincaptcha\" value=\"(.*?)\"").Match(result).Groups[1].Value;19 20             //开始登录21             url = "http://passport.cnblogs.com/login.aspx";22             List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>();23             paramList.Add(new KeyValuePair<string, string>("__EVENTTARGET", ""));24             paramList.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));25             paramList.Add(new KeyValuePair<string, string>("__VIEWSTATE", __VIEWSTATE));26             paramList.Add(new KeyValuePair<string, string>("__VIEWSTATEGENERATOR", "C2EE9ABB"));27             paramList.Add(new KeyValuePair<string, string>("__EVENTVALIDATION", __EVENTVALIDATION));28             paramList.Add(new KeyValuePair<string, string>("tbUserName", username));29             paramList.Add(new KeyValuePair<string, string>("tbPassword", password));30             paramList.Add(new KeyValuePair<string, string>("LBD_VCID_c_login_logincaptcha", LBD_VCID_c_login_logincaptcha));31             paramList.Add(new KeyValuePair<string, string>("LBD_BackWorkaround_c_login_logincaptcha", "1"));32             //paramList.Add(new KeyValuePair<string, string>("CaptchaCodeTextBox", imgCode));33             paramList.Add(new KeyValuePair<string, string>("btnLogin", "登  录"));34             paramList.Add(new KeyValuePair<string, string>("txtReturnUrl", "http://home.cnblogs.com/"));35             response = httpClient.PostAsync(new Uri(url), new FormUrlEncodedContent(paramList)).Result;36             result = response.Content.ReadAsStringAsync().Result;37 38             if (result.Contains("用户登录"))39                 return false;40             else if (result.Contains("返回博客园首页"))41                 return true;42             else43                 return false;44         }

复制代码

然后就是发布的代码

复制代码

 1         /// <summary> 2         /// 发布转发文章 3         /// </summary> 4         /// <returns></returns> 5         public bool Release(string title = "", string content = "") 6         { 7             List<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); 8             paramList.Add(new KeyValuePair<string, string>("__VIEWSTATE", @"")); 9             paramList.Add(new KeyValuePair<string, string>("__VIEWSTATEGENERATOR", "FE27D343"));10             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$txbTitle", title));11             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$EditorBody", content));12             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$Advanced$ckbPublished", "on"));13             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$Advanced$chkDisplayHomePage", "on"));14             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$Advanced$chkComments", "on"));15             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$Advanced$chkMainSyndication", "on"));16             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$Advanced$txbEntryName", ""));17             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$Advanced$txbExcerpt", ""));18             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$Advanced$txbTag", ""));19             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$Advanced$tbEnryPassword", ""));20             paramList.Add(new KeyValuePair<string, string>("Editor$Edit$lkbPost", "发布"));21 22             HttpResponseMessage response = httpClient.PostAsync(new Uri("http://i.cnblogs.com/EditPosts.aspx?opt=1"), new FormUrlEncodedContent(paramList)).Result;23             String result = response.Content.ReadAsStringAsync().Result;24             if (result.Contains("发布成功"))25                 return true;26             else27                 return false;28 29         }

复制代码

 关键代码就只有这么几句,没什么好讲的。我也不知其所以然。

不说了 上效果图。

转发成功。

说明:

   因为我登录博客园没有要输入验证码的情况,所以我就没有做验证码的处理了。大家的应该也不用输验证码吧。

还有就是没有做其他主流博客直接的相互转发,只有博客园内的转发。同学们有兴趣可以在次基础上做修改,欢迎改得“面目全非”。

环境:

  vs2013  .net4.5

功能:

  支持博客园一键转发,密码保存。下次就可以不用输入密码了。但是没有做加密措施。同学们可以自己接着折腾。

 

好了~最后发源码了。如果能感兴趣,拿起您的小手点个赞。如果您要反对 求您给你理由。


點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消