Use su Fei httphelper to develop an automatic update and Publishing Article program,

Source: Internet
Author: User

Use su Fei httphelper to develop an automatic update and Publishing Article program,

Recently launched a new website, specifically to collect online sign-in to make money, prize activities and so on the website I want to set up the treasures of http://www.591jfb.com. A new topic "update every day" is created, so you need to log on to the website background every day to publish articles. It feels a little complicated, so you just want to find a way to save effort, so we have this article.

After searching and downloading the httphelper provided by Su Fei, I wrote a program in comparison to the example. The returned html is always an error page, so I flipped through the post on the sufeinet forum, I found someone using sufei's Development Assistant to test remote Publishing. So I downloaded the code and tested it. The result was successful. The difference between the code generated by sufei's Development Assistant and the code I wrote was as follows, eventually, the problem occurs on the cookie. Directly Write result. The cookie value assigned by the cookie has some path =/similar strings.

The final code is as follows:

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 button#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 ", // The default value of URL option is 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 % 3 Esxgsxg % 3C % 2Fp % 3E & meta_keywords = & meta_description = & Alias = & Tag = & amp; 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 );}}}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.