private bool sendarticle(WXArticleInfo info) { bool rs = false; string urlstr = "http://dg.ce.kankan.ml/dede/article_add.php"; HttpItem item2 = new HttpItem() { URL = urlstr, //URL 必需项 Method = "post", //URL 可选项 默认为Get Timeout = 100000, //连接超时时间 可选项默认为100000 ReadWriteTimeout = 30000, //写入Post数据超时时间 可选项默认为30000 IsToLower = false, //得到的HTML代码是否转成小写 可选项默认转小写 UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0", //用户的浏览器类型,版本,操作系统 PostDataType = PostDataType.Byte, ContentType = "multipart/form-data; boundary=---------------------------7e128826811ec", Referer = "http://dg.ce.kankan.ml", ResultType = ResultType.String,//返回数据类型,是Byte还是String ProxyIp = "127.0.0.1:8888", }; //0标题1来源2作者3内容4时间 string strbody = System.IO.File.ReadAllText("postt.txt"); strbody = string.Format(strbody, "biaoti111", "biaoti2222", "标题2222", "内容2222", DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd")); byte[] bytedate = System.Text.Encoding.UTF8.GetBytes(strbody); item2.PostdataByte = bytedate; HttpResult result2 = httpClient.GetHtml(item2); Console.Write(result2.Html); return(rs); }
public bool run(WXArticleInfo info) { bool rs = false; rs = login(); sendarticle(info); return(rs); }
public void Run() { //开始运行 taskflag = 1; taskStartTime = DateTime.Now; WXGZHArticle.LogUtil.Log(url + "准备开始获取网页信息"); FinalHtml html = new FinalHtml(); if (html.Run(url)) { WXGZHArticle.LogUtil.Log(url + "网页信息获取成功"); try { WXArticleInfo rs = WXArticleAdapter.GetArticle(html.HtmlString); string articleid = Guid.NewGuid().ToString("N"); bool dbrs = WXArticleDBHelper.InseartDB(rs, articleid); if (dbrs) { WXGZHArticle.LogUtil.Log(url + "操作完成已写入数据库!"); } else { WXGZHArticle.LogUtil.Log(url + "操作失败未写入数据库!"); } WXGZHDownload.DeDe.DeDePublic1 dede = new WXGZHDownload.DeDe.DeDePublic1(); if (dede.run(rs, sendtype)) { WXGZHArticle.LogUtil.Log(url + "已发布到网站!"); if (WXArticleDBHelper.ResetArticleFlag(articleid, 1)) { WXGZHArticle.LogUtil.Log(url + "数据库更新成功!"); } else { WXGZHArticle.LogUtil.Log(url + "数据库更新失败!"); } } else { WXGZHArticle.LogUtil.Log(url + "未发布到网站!"); } WXGZHArticle.LogUtil.Log(url + "采集及发布过程结束!"); } catch (System.Exception ex) { WXGZHArticle.LogUtil.Log(url + "采集过程出现异常!" + ex.Message); WXGZHArticle.LogUtil.Log(url + ex.StackTrace); } } //运行结束 taskflag = 2; }
/// <summary> /// 修改图文素材列表中的文章接口 /// </summary> /// <param name="mediaId"></param> /// <param name="index"></param> /// <param name="article"></param> /// <returns></returns> public async Task <WXBaseResp> UpdateArticleAsync(string mediaId, int index, WXArticleInfo article) { var req = new OssHttpRequest(); req.HttpMethod = HttpMethod.Post; req.AddressUrl = string.Concat(m_ApiUrl, "/cgi-bin/material/update_news"); req.CustomBody = JsonConvert.SerializeObject(new { media_id = mediaId, index = index, articles = article }); return(await RestCommonPlatAsync <WXBaseResp>(req)); }
public bool run(WXArticleInfo info, int type1) { bool rs = false; rs = login(); if (rs) { rs = sendarticle(info, type1); } return(rs); }
private bool sendarticle(WXArticleInfo info, int type1) { bool rs = false; MultipartFormDataContent mm = new MultipartFormDataContent(); AddFlagIntoParm(mm); mm.Add(new StringContent("1"), "channelid"); mm.Add(new StringContent("save"), "dopost"); mm.Add(new StringContent(info.title), "title"); mm.Add(new StringContent(""), "shorttitle"); mm.Add(new StringContent(""), "redirecturl"); mm.Add(new StringContent(""), "tags"); mm.Add(new StringContent("2"), "weight"); mm.Add(new StringContent(info.sltImageUrl), "picname"); mm.Add(new StringContent(info.source), "source"); mm.Add(new StringContent(info.author), "writer"); mm.Add(new StringContent(type1.ToString()), "typeid"); mm.Add(new StringContent(""), "typeid2"); mm.Add(new StringContent(""), "keywords"); mm.Add(new StringContent("1"), "autokey"); mm.Add(new StringContent(""), "description"); mm.Add(new StringContent(""), "dede_addonfields"); mm.Add(new StringContent("0"), "remote"); mm.Add(new StringContent("1"), "autolitpic"); mm.Add(new StringContent("1"), "needwatermark"); mm.Add(new StringContent("hand"), "sptype"); mm.Add(new StringContent("5"), "spsize"); mm.Add(new StringContent(info.content), "body"); mm.Add(new StringContent(""), "voteid"); mm.Add(new StringContent("0"), "notpost"); mm.Add(new StringContent("112"), "click"); mm.Add(new StringContent("0"), "sortup"); mm.Add(new StringContent(""), "color"); mm.Add(new StringContent("0"), "arcrank"); mm.Add(new StringContent("0"), "money"); mm.Add(new StringContent(DateTime.Now.ToString("yyyy-MM-dd HH:mm")), "pubdate"); mm.Add(new StringContent("0"), "ishtml"); mm.Add(new StringContent(""), "filename"); mm.Add(new StringContent(""), "templet"); mm.Add(new StringContent("28"), "imageField.x"); mm.Add(new StringContent("11"), "imageField.y"); var response1 = httpClient.PostAsync(new Uri(DedeStaticValues.DedeAddarticleUrl), mm).Result; string result = response1.Content.ReadAsStringAsync().Result; if (result.Contains("成功发布文章")) { result = httpClient.GetStringAsync(new Uri(DedeStaticValues.DedeSitemapUrl)).Result; rs = true; } return(rs); }
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { string _allhtmlinfo = this.webBrowser1.DocumentText; string _bodyhtmlinfo = this.webBrowser1.Document.Body.InnerHtml; this.webBrowser1.Stop(); WXArticleInfo rs = WXArticleAdapter.GetArticle(_bodyhtmlinfo); string articleid = Guid.NewGuid().ToString("N"); bool dbrs = WXArticleDBHelper.InseartDB(rs, articleid); if (dbrs) { this.textBox2.Text += "操作完成已写入数据库!"; } else { this.textBox2.Text += "操作失败未写入数据库!"; } WXGZHDownload.DeDe.DeDePublic1 dede = new WXGZHDownload.DeDe.DeDePublic1(); if (dede.run(rs)) { this.textBox2.Text += "已发布到网站!"; if (WXArticleDBHelper.ResetArticleFlag(articleid, 1)) { this.textBox2.Text += "数据库更新成功!"; } else { this.textBox2.Text += "数据库更新失败!"; } } else { this.textBox2.Text += "未发布到网站!"; } this.textBox2.Text += "采集及发布过程结束!\r\n"; }