我想要实现的是使用idhtp1.GET从网页返回一些数据 当我这样做时:
sGeo := RemoveWhiteSpace('http://www.robin-william.net/Osiris/geo.php?ip=IPHERE');
redt1.Lines.Add(idhtpGeo.Get(sGeo));
它完美无缺,但是一旦我这样做了:
sGeo := RemoveWhiteSpace('http://www.robin-william.net/Osiris/geo.php?ip=' + sData);
(添加了sData)它给了我错误DOCTYPE html。
以下是来源的一部分:
procedure TfrmMap.GetGeo(sData : string);
begin
try
idhtpGeo.ConnectTimeout := 5000;
idhtpGeo.HandleRedirects := True;
sGeo := RemoveWhiteSpace('http://www.robin-william.net/Osiris/geo.php?ip=' + sData);
redt1.Lines.Add(sGeo);
redt1.Lines.Add(idhtpGeo.Get(sGeo));
except
MessageDlg('Failed to load Geo Data!', mtError, [mbOK], 0);
end;
end;
sData就是IP。我也尝试使用SynaCode单元对URL(sGeo)进行编码,它没有给我任何错误,但返回的数据不正确。
编码的URL如下所示:
http://www.robin-william.net/Osiris/geo.php?ip=88.106.170.45%0A
非常感谢任何帮助。
答案 0 :(得分:0)
没关系我发现了问题。只需要修剪名为sData的字符串。