vb没这函数。有人能帮忙做成一个dll或控件吗,以便调用
使用HttpWebRequest向网站模拟上传数据-(摘自greystar的专栏)
最近有个朋友离开IT行业二年的朋友说要实现用程序向某个网站的页面上传数据,他是意思是每天有几十条数据要在网站页面上填写,很烦,最好用程序来写。网站页面是用POST传递的,同时没有验证码之类的东东,只有一点限制就是5分种内不能填写二次记录。这一切都好办。using System.Web;
using System.Net;
using System.Text;
using System.IO;//创建对某个网站页面的请求HttpWebRequest myRequest = (HttpWebRequest )WebRequest.Create("http://www.website.com/a.asp")//上传的数据,”TextBox1“这些东东是网站页面里的控件ID,如果要上传多个值也是用&来分隔 string postData="TextBox1="+this.textBox1.Text+"&TextBox2="+this.textBox2.Text+"&TextBox3="+this.textBox3.Text+"&TextBox4="+this.textBox4.Text;
ASCIIEncoding encoding=new ASCIIEncoding();
byte[] byte1=encoding.GetBytes(postData);//最终编码后要上传的数据
// Set the content type of the data being posted.
myRequest.ContentType="application/x-www-form-urlencoded";
myRequest.Method="post";//post上传方式
// Set the content length of the string being posted.
myRequest.ContentLength=postData.Length;
Stream newStream=myRequest.GetRequestStream();
newStream.Write(byte1,0,byte1.Length);
一切就OK了,如果你想上传后看到网站的内容的话,可以在程序里放一个IE控件,使用axWebBrowser1.Navigate("http://www.website.com/a.asp");
axWebBrowser1.Refresh2();
使用HttpWebRequest向网站模拟上传数据-(摘自greystar的专栏)
最近有个朋友离开IT行业二年的朋友说要实现用程序向某个网站的页面上传数据,他是意思是每天有几十条数据要在网站页面上填写,很烦,最好用程序来写。网站页面是用POST传递的,同时没有验证码之类的东东,只有一点限制就是5分种内不能填写二次记录。这一切都好办。using System.Web;
using System.Net;
using System.Text;
using System.IO;//创建对某个网站页面的请求HttpWebRequest myRequest = (HttpWebRequest )WebRequest.Create("http://www.website.com/a.asp")//上传的数据,”TextBox1“这些东东是网站页面里的控件ID,如果要上传多个值也是用&来分隔 string postData="TextBox1="+this.textBox1.Text+"&TextBox2="+this.textBox2.Text+"&TextBox3="+this.textBox3.Text+"&TextBox4="+this.textBox4.Text;
ASCIIEncoding encoding=new ASCIIEncoding();
byte[] byte1=encoding.GetBytes(postData);//最终编码后要上传的数据
// Set the content type of the data being posted.
myRequest.ContentType="application/x-www-form-urlencoded";
myRequest.Method="post";//post上传方式
// Set the content length of the string being posted.
myRequest.ContentLength=postData.Length;
Stream newStream=myRequest.GetRequestStream();
newStream.Write(byte1,0,byte1.Length);
一切就OK了,如果你想上传后看到网站的内容的话,可以在程序里放一个IE控件,使用axWebBrowser1.Navigate("http://www.website.com/a.asp");
axWebBrowser1.Refresh2();
Private Sub InetReg()
Dim strUrl As String
Dim UserName As String
Dim PassWord As String
Dim strPost As String
Dim strHttpHead As String
Dim i As Integer
WorkId = 0
RegTimes = RegTimes + 1
strUrl = txtUrl.Text
UserName = GetRnd(0)
PassWord = GetRnd(0)
strPost = "action=save&name=" & UserName & "&sex=1&psw=" & PassWord & "&pswc=" & PassWord & "&quesion=222222222&answer=111111111&e_mail=" & GetRnd(1)
strHttpHead = "CONNECTION: Keep -Alive" & Chr(13) & "Content-Type: application/x-www-form-urlencoded " & Chr(13) & "ACCEPT_ENCODING: gzip , deflate" & Chr(13) & "ACCEPT_LANGUAGE: zh -cn" & Chr(13) & "REFERER:" & strUrl & "reg.asp?action=apply"
InetHttp.Execute strUrl & "reg.asp", "Post", strPost, strHttpHead
txtUser.Text = UserName
txtPassword.Text = PassWord
End Sub
如果需要帮你完成你要的功能,请和我QQ联系:250009333,,不过是有偿的喔