我用HTMLDocument抓一个网页上的所有连接,但是其中有一部分是相对路径,请问有什么函数可以把这个相对路径转换成绝对的连接

解决方案 »

  1.   

    程序中用application.Exename
    网页中不知道帮你顶吧
      

  2.   

    你既然是用「HTMLDocument抓"一个"网页上」,那你当然知道那个网页的网址吧!比如 http://myserver/mypage,那你抓到的每一个路径都在前面加上那串字(http://myserver/mypage/),不就可以了吗﹖
      

  3.   

    ../../如遇到这情况,可以用切割函数处理
    function split(input:string;schar: char;s:integer):string;
    var
     i,n:integer;
     schop: string;
    begin
     n := 0;
     for i := 1 to length(input) + 1 do
      begin 
       if (input[i] = schar) or (i=length(input)+1) then
        begin
         inc(n);
         if (n = s) then
          split := schop
         else
          schop := '';
         end
       else
        schop := schop + input[i];
      end;
    end;function SplitString(const Source,ch:string):TStringList;
    var
     temp:String;
     i:Integer;
    begin
     Result:=TStringList.Create; //如果是空自符串则返回空列表
     if Source='' then exit;
     temp:=Source;
     i:=pos(ch,Source);
     while i<>0 do
      begin
       Result.add(copy(temp,0,i-1));
       Delete(temp,1,i);
       i:=pos(ch,temp);
      end;
     Result.add(temp);
    end;