关于delphi中idhttp网页提交的方法?
这是一个申请key的页面:https://license.avira.com/en/promotion-hylm9fbv7chaxs8zbl83?id=JVgkM1BNU...
这是一个申请key的页面:https://license.avira.com/en/promotion-hylm9fbv7chaxs8zbl83?id=JVgkM1BNUn
我想要用idhttp.post方法进行自动提交,如下
procedure TForm1.Button1Click(Sender: TObject);
var
sPost, shtml: TStringlist;
sData: TMemoryStream;
begin
sPost := TStringlist.Create;
sData := TMemoryStream.Create;
try
sPost.Add('customerSalutationId=MR');
sPost.Add('customerFirstname=sdjl');
sPost.Add('customerLastname=sfjljkio');
sPost.Add('customerEmail=sdfsdfjoj@qq.com');
sPost.Add('customerCountryId=Italy');
IdHTTP1.Post('https://license.avira.com//en/promotion-hylm9fbv7chaxs8zbl83?id=Y8on000002',
sPost, sData);
except
ShowMessage('error');
sPost.Free;
sData.Free;
end;
sPost.Free;
sData.Free;
end;
但是点击button后出现"无效指针操作"的错误提示,请问问题出现在哪里了,另外提交后返回的应该是一个浏览授权文件的页面,请问应该如何接收这个页面? 展开
我想要用idhttp.post方法进行自动提交,如下
procedure TForm1.Button1Click(Sender: TObject);
var
sPost, shtml: TStringlist;
sData: TMemoryStream;
begin
sPost := TStringlist.Create;
sData := TMemoryStream.Create;
try
sPost.Add('customerSalutationId=MR');
sPost.Add('customerFirstname=sdjl');
sPost.Add('customerLastname=sfjljkio');
sPost.Add('customerEmail=sdfsdfjoj@qq.com');
sPost.Add('customerCountryId=Italy');
IdHTTP1.Post('https://license.avira.com//en/promotion-hylm9fbv7chaxs8zbl83?id=Y8on000002',
sPost, sData);
except
ShowMessage('error');
sPost.Free;
sData.Free;
end;
sPost.Free;
sData.Free;
end;
但是点击button后出现"无效指针操作"的错误提示,请问问题出现在哪里了,另外提交后返回的应该是一个浏览授权文件的页面,请问应该如何接收这个页面? 展开
展开全部
function GetString(tStr,sStr,eStr :string):string;
var
sPos,ePos :integer;
begin
Result := '';
sPos := Pos(sStr,tStr);
if sPos > 0 then
begin
tStr := Copy(tStr,sPos+Length(sStr),Length(tStr)-sPos-Length(sStr)+1);
ePos := Pos(eStr,tStr);
if ePos > 0 then
Result := Copy(tStr,1,ePos-1);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sl :TStringList;
s :string;
begin
s := Utf8ToAnsi(IdHTTP1.Get('https://license.avira.com/en/promotion-hylm9fbv7chaxs8zbl83'));
s := GetString(s,'<form method="POST" action="','" id="form" name="form">');
sl := TStringList.Create;
try
sl.Add('customerSalutationId=MR_');
sl.Add('customerFirstname=sdjl');
sl.Add('customerLastname=sfjljkio');
sl.Add('customerEmail=sdfsdfjoj@qq.com');
sl.Add('customerCountryId=CN');
sl.Add('buttonActivate=Request license now');
s := Utf8ToAnsi(IdHTTP1.Post('https://license.avira.com/'+s,sl));
if Pos(UpperCase('A license file has been already generated for this email address'),UpperCase(s)) > 0 then
ShowMessage('该邮箱已经使用')
else
begin
s := GetString(s,'<a class="hyperLink" href="','">License Overview</a>');
s := Utf8ToAnsi(IdHTTP1.Get('https://license.avira.com/en/'+s));
ShowMessage('License No.: ' + GetString(s,'License No.: ',' '));
end;
finally
FreeAndNil(sl);
end;
end;
var
sPos,ePos :integer;
begin
Result := '';
sPos := Pos(sStr,tStr);
if sPos > 0 then
begin
tStr := Copy(tStr,sPos+Length(sStr),Length(tStr)-sPos-Length(sStr)+1);
ePos := Pos(eStr,tStr);
if ePos > 0 then
Result := Copy(tStr,1,ePos-1);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
sl :TStringList;
s :string;
begin
s := Utf8ToAnsi(IdHTTP1.Get('https://license.avira.com/en/promotion-hylm9fbv7chaxs8zbl83'));
s := GetString(s,'<form method="POST" action="','" id="form" name="form">');
sl := TStringList.Create;
try
sl.Add('customerSalutationId=MR_');
sl.Add('customerFirstname=sdjl');
sl.Add('customerLastname=sfjljkio');
sl.Add('customerEmail=sdfsdfjoj@qq.com');
sl.Add('customerCountryId=CN');
sl.Add('buttonActivate=Request license now');
s := Utf8ToAnsi(IdHTTP1.Post('https://license.avira.com/'+s,sl));
if Pos(UpperCase('A license file has been already generated for this email address'),UpperCase(s)) > 0 then
ShowMessage('该邮箱已经使用')
else
begin
s := GetString(s,'<a class="hyperLink" href="','">License Overview</a>');
s := Utf8ToAnsi(IdHTTP1.Get('https://license.avira.com/en/'+s));
ShowMessage('License No.: ' + GetString(s,'License No.: ',' '));
end;
finally
FreeAndNil(sl);
end;
end;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询