用代码向网站提交数据

用代码向网站提交数据

左直拳

 

可以用代码模拟浏览器向网站提交数据:

string sUrl = "http://。。。。";//目标网址

Uri target = new Uri(sUrl);

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(target);

 

req.ReadWriteTimeout = 10000;

req.Timeout = 10000;

req.MaximumAutomaticRedirections = 5;

req.MaximumResponseHeadersLength = 5;

req.AllowAutoRedirect = true;

//装扮成一个浏览器,欺骗那个网址

req.UserAgent = "Mozilla/6.0 (compatible; MSIE 6.0; Windows NT 5.1)";

 

req.Method = "POST";

req.ContentType = "application/x-www-form-urlencoded";

string postData = "voteid=15196&markinfo=0&checktype=2&op=69884";//传递的数据

byte[] arPostData = Encoding.UTF8.GetBytes(postData);

req.ContentLength = arPostData.Length;

Stream newStream = req.GetRequestStream();

newStream.Write(arPostData, 0, arPostData.Length);

newStream.Close();

 

如果目标网址需要输入验证码,则死翘翘。

 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值