使用蘇飛httphelper開發自動更新發布文章程式

來源:互聯網
上載者:User

標籤:

最近新上線了一個網站,專門收集網上籤到賺錢,有獎活動等等的網站 我就要集分寶 http://www.591jfb.com。建立立 了一個欄目“每日更新”,這樣就需要每天都登入到網站後台去發布文章,感覺有些繁瑣,於是就想找點省勁的辦法,於是便有了此文。

搜尋下載了蘇飛提供的httphelper,比著例子寫了一下程式,結果返回的html總是錯誤頁,於是又翻sufeinet論壇上面的文章,搜尋到有人用蘇飛開發助手測試遠程發布,於是也下載下來測試了一下,結果成功了,對照蘇飛開發助手產生的程式碼和我寫的代碼的差別,最終發現問題出現在cookie上面。直接寫result.cookie賦值的cookie值有一些path=/ 類似的字串。

最終使用代碼如下:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using Utility;namespace PostArticle2{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }        private void button1_Click(object sender, EventArgs e)        {            HttpHelper http = new HttpHelper();            HttpItem item = null;            HttpResult result = null;                      item = new HttpItem()            {                URL = "http://php.sxg.com/zb_system/cmd.php?act=verify",                Referer = "http://php.sxg.com/zb_system/login.php",                Method = "post",//URL     可選項 預設為Get                ContentType = "application/x-www-form-urlencoded",                Postdata = "btnPost=%E7%99%BB%E5%BD%95&username=username&password=pwd&savedate=0&dishtml5=0",            };            result = http.GetHtml(item);            string cookie = string.Empty;            foreach (CookieItem s in HttpCookieHelper.GetCookieList(result.Cookie))            {                cookie += HttpCookieHelper.CookieFormat(s.Key, s.Value);            }            item = new HttpItem()            {                URL = "http://php.sxg.com/zb_system/cmd.php?act=ArticlePst",                Referer = "http://php.sxg.com/zb_system/admin/edit.php?act=ArticleEdt",                Cookie = cookie,                Method = "post",                Postdata = "ID=0&Type=0&Title=1720sxg&Content=%3Cp%3Esxgsxg%3C%2Fp%3E&meta_keywords=&meta_description=&Alias=&Tag=&Intro=&CateID=1&Status=0&Template=single&AuthorID=1&PostTime=2015-01-13+11%3A37%3A01&IsTop=0&IsLock=0",                Allowautoredirect = true,                ContentType = "application/x-www-form-urlencoded",                Host = "php.sxg.com",                ResultType = ResultType.String            };            http.GetHtml(item);        }    }}

使用蘇飛httphelper開發自動更新發布文章程式

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.