truedeity Posted May 12, 2010 Posted May 12, 2010 (edited) i'm trying to create some software that does this. however, i'm having some problems with the posting on blogengine.net blogs. i'm using a blog to test on, with a button click event i begin the code. NameValueCollection mycol = new NameValueCollection(); mycol.Add("ctl00_cphBody_CommentView1_txtName", "Get Backlinks"); mycol.Add("ctl00_cphBody_CommentView1_txtEmail", "danman3_1999@yahoo.com"); mycol.Add("ctl00_cphBody_CommentView1_txtWebsite", "http://www.liquidresults.com"); mycol.Add("ctl00_cphBody_CommentView1_ddlCountry", "US"); mycol.Add("ctl00_cphBody_CommentView1_txtContent", "Nice info you provided I would like to know more."); // mycol.Add("__EVENTVALIDATION", "/wEWpQECjLGF3gICyqvt2wMC1eX3owwCruLkxgwC/ubfrwUCwYnNwAkCwYnlwAkCwond3wkCwYm9wAkCwYnpwAkCwYmJwAkCwYmFwAkCwYnd3wkCwImVwAkCwInZ3wkCwInJwAkCwInd3wkCwInxwAkCwIn5wAkCwIm9wAkCwIntwAkCwInRwAkCw4n5wAkCk6vrigECw4nlwAkCw4nxwAkCw4m9wAkCtom9wAkCw4nd3wkCwonhwAkCwonxwAkCxYnBwAkCxYnRwAkCs4mNwAkCxYnJwAkCxInxwAkCxImZwAkCxIm9wAkCx4nJwAkCwonJwAkCx4m9wAkCx4mFwAkCtontwAkCtonhwAkCtomJwAkCuYmBwAkCuYntwAkCuYnFwAkCuYm9wAkCuYm5wAkCuYnJwAkCronhwAkCuYnlwAkCuYmFwAkCuInpwAkCuIm1wAkCuInxwAkCu4nd3wkCu4nJwAkCu4m9wAkCu4mRwAkCu4nRwAkCuomNwAkCuon9wAkCuonZ3wkCuomZwAkCuomFwAkCuomJwAkCvYnxwAkCvYnhwAkCvYnZ3wkCvYmNwAkCvYmFwAkCvYnV3wkCvYntwAkCvYn5wAkCvIm1wAkCvInlwAkCvInd3wkCvImZwAkCvInxwAkCv4npwAkCron5wAkCronZ3wkCw4ntwAkCronJwAkCromVwAkCronlwAkCromFwAkCvYnBwAkCrom9wAkCsYn5wAkCromVwAkCsInxwAkCsImJwAkCs4n5wAkCw4mBwAkCs4nRwAkCs4nhwAkCs4mZwAkCqIn5wAkCxYmBwAkCs4nJwAkCw4mVwAkCs4nZ3wkCsomRwAkCsomVwAkCsomFwAkCsontwAkCsom9wAkCwYnJwAkCtYn5wAkCx4n9wAkCtYmBwAkCtYnZ3wkCtYnd3wkCtInJwAkCtIntwAkCqYnJwAkCqImRwAkCubT85wMC8o/Y3gMC3pKg4woC3pL8iwgC3pKIbwLzufr3DQLzuZarBALzuaKODwLzub7hBwLzucrEDgLzuea/AQLzufKSCALzuY52AvO52p4GAvO59vEOAtjTurYEAtjT1ukMAtjT4swHAtjT/qcOAtjTipsBAtjTpv4JAtjTslEC2NPOtAsC2NOa3Q4C2NO2sAEC/fqYmQIC/fq0/AoC/frA1w0C/frcigQC/fro7QwC/fqEwQcC/fqQpA4C/fqsnwEC/fr4pwQC/fqUmw8CsJmV7AoCsJmhxw0CsJm9ugQCsJnJnQ8CsJnl8AcCsJnxqw4CsJmNjwECsJmZ4gkCsJn1ig8CxK3qwQyWFf50tdLjV9Y6yewwim961lI4pw=="); MyHtmlDocument md = new MyHtmlDocument(mycol, @"http://blog.muecs.com/post/New-features-updated-for-your-enterprise-to-become-more-social.aspx"); MyHtmlDocument leverages HtmlAgilityPack, code follows. using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Text; using HtmlAgilityPack; using System.IO; using System.Net; namespace backlink_maker { public class MyHtmlDocument : HtmlAgilityPack.HtmlWeb { public MyHtmlDocument(NameValueCollection nvc, string url) { this.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)"; SubmitFormValues(nvc, url); } public HtmlDocument SubmitFormValues(NameValueCollection fv, string url) { // Attach a temporary delegate to handle attaching // the post back data HtmlAgilityPack.HtmlWeb.PreRequestHandler handler = delegate(HttpWebRequest request) { string payload = this.AssemblePostPayload(fv); byte[] buff = Encoding.ASCII.GetBytes(payload.ToCharArray()); request.ContentLength = buff.Length; request.ContentType = "application/x-www-form-urlencoded"; System.IO.Stream reqStream = request.GetRequestStream(); reqStream.Write(buff, 0, buff.Length); return true; }; this.PreRequest += handler; HtmlDocument doc = this.Load(url, "POST"); this.PreRequest -= handler; return doc; } private string AssemblePostPayload(NameValueCollection fv) { StringBuilder sb = new StringBuilder(); foreach (String key in fv.AllKeys) { sb.Append("&" + key + "=" + fv.Get(key)); } return sb.ToString().Substring(1); } } } any suggestions? comment doesnt seem to post on URL removed Edited May 13, 2010 by Dak
mooeypoo Posted May 13, 2010 Posted May 13, 2010 Auto-posting comments with links is known as spam, and is illegal in many countries, and is against the netiquette in all countries. Asking a *forum* that otherwise fights spam on a daily basis to help you formulate spam bots is simply bad taste. Closed.
Recommended Posts