我用IdHTTP1做了一个自动提交网页的程序,但我发现这只对脚本语言有用例如asp或php,但对asp.net就不能post,因为asp.net提交网页内容是写在按钮事件里的,不能直接用post加参数来实现,那asp.net如何用post实现提交呢?以下是我写的提交asp的代码,如何改成提交asp.net代码呢?
idHTTP1:=TidHTTp.create(self);
idHTTP1.HandleRedirects := True; Response := TStringStream.Create('');
postList := TStringList.Create;
try
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon)';
postList.Clear; postList.Add( 'name=哈哈哈');
postList.Add( 'nickname=哈哈哈');
postList.Add( 'tel=哈哈哈');
postList.Add( 'post=哈哈哈');
postList.Add( '[email protected]');
postList.Add( 'refer=1');
postList.Add( 'title=哈哈哈');
postList.Add( 'content=哈哈哈');
postList.Add( 'kind=1');
IdHTTP1.Post('http://www.xmhouse.com/liuyuan/addsave.asp',postList,Response); ShowMessage('提交成功!');
finally
Response.Free;
postList.Free;
idHTTP1:=TidHTTp.create(self);
idHTTP1.HandleRedirects := True; Response := TStringStream.Create('');
postList := TStringList.Create;
try
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon)';
postList.Clear; postList.Add( 'name=哈哈哈');
postList.Add( 'nickname=哈哈哈');
postList.Add( 'tel=哈哈哈');
postList.Add( 'post=哈哈哈');
postList.Add( '[email protected]');
postList.Add( 'refer=1');
postList.Add( 'title=哈哈哈');
postList.Add( 'content=哈哈哈');
postList.Add( 'kind=1');
IdHTTP1.Post('http://www.xmhouse.com/liuyuan/addsave.asp',postList,Response); ShowMessage('提交成功!');
finally
Response.Free;
postList.Free;
你不能提交的原因应该是没有仔细分析ASP.NET生成的HTML源码(例如有的网站会在客户端生成一个SESSIONID或TOKEN,放到表单中,提交后进行验证,如果无效,是拒绝进行处理的),和什么提交内容放在按钮中一点关系都没有。
能不能推荐一两个好用的抓包工具,谢谢!
和
WSockExpert
都挺好用!
(Status-Line) HTTP/1.1 200 OK
IdHTTP1.Response 下没有HEADER属性呀,能不能说得具体些呢?谢谢!