Delphi Dünyası Facebook'ta

Kodbank İndir

! CODEBANK 2012 !

İNDİRMEK&DETAYLI BİLGİ ALMAK İÇİN BURAYI TIKLAYINIZ.

Gönderen Konu: Internet - HTML'den resim linklerini almak  (Okunma sayısı 2828 defa)

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı CMNSOFT

  • Delphi 2 Level 4
  • ****
  • İleti: 82
  • Rep: +2/-2
  • Cinsiyet: Bay
    • http://www.cmnsoft.com
Internet - HTML'den resim linklerini almak
« : 23 Ekim 2005 02:16:10 »
Kod:  (Unknown Language)
  1. Uses
  2.    mshtml, ActiveX, COMObj, IdHTTP, idURI;

Kod:  (Unknown Language)
  1. Procedure GetImageLinks(AURL: String; AList: TStrings) ;
  2. var
  3.    IDoc : IHTMLDocument2;
  4.    strHTML : String;
  5.    v : Variant;
  6.    x : integer;
  7.    ovLinks : OleVariant;
  8.    DocURL : String;
  9.    URI : TidURI;
  10.    ImgURL : String;
  11.    idHTTP : TidHTTP;
  12. begin
  13.    AList.Clear;
  14.    URI := TidURI.Create(AURL) ;
  15.    try
  16.      DocURL := 'http://' + URI.Host;
  17.      if URI.Path <> '/' then
  18.        DocURL := DocURL + URI.Path;
  19.    finally
  20.      URI.Free;
  21.    end;
  22.    Idoc:=CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
  23.    try
  24.      IDoc.designMode:='on';
  25.      while IDoc.readyState<>'complete' do
  26.        Application.ProcessMessages;
  27.      v:=VarArrayCreate([0,0],VarVariant) ;
  28.      idHTTP := TidHTTP.Create(nil) ;
  29.      try
  30.        strHTML := idHTTP.Get(AURL) ;
  31.      finally
  32.        idHTTP.Free;
  33.      end;
  34.      v[0]:= strHTML;
  35.      IDoc.write(PSafeArray(System.TVarData(v).VArray)) ;
  36.      IDoc.designMode:='off';
  37.      while IDoc.readyState<>'complete' do
  38.        Application.ProcessMessages;
  39.      ovLinks := IDoc.all.tags('IMG') ;
  40.      if ovLinks.Length > 0 then
  41.      begin
  42.        for x := 0 to ovLinks.Length-1 do
  43.        begin
  44.          ImgURL := ovLinks.Item(x).src;
  45.          // The stuff below will probably need a little tweaking
  46.          // Deteriming and turning realtive URLs into absolute URLs
  47.          // is not that difficult but this is all I could come up with
  48.          // in such a short notice.
  49.          if (ImgURL[1] = '/') then
  50.          begin
  51.            // more than likely a relative URL so
  52.            // append the DocURL
  53.            ImgURL := DocURL + ImgUrl;
  54.          end
  55.          else
  56.          begin
  57.            if (Copy(ImgURL, 1, 11) = 'about:blank') then
  58.            begin
  59.              ImgURL := DocURL + Copy(ImgUrl, 12, Length(ImgURL)) ;
  60.            end;
  61.          end;
  62.          AList.Add(ImgURL) ;
  63.        end;
  64.      end;
  65.    finally
  66.      IDoc := nil;
  67.    end;
  68. End;



Kullanım Şekli
Kod:  (Unknown Language)
  1. Procedure TForm1.Button1Click(Sender: TObject) ;
  2. Begin
  3.    GetImageLinks('http://www.cmnsoft.com/cmn/index.php', Memo1.Lines) ;
  4. End;
« Son Düzenleme: 07 Haziran 2007 01:42:07 by kocaturk »
:::::::::::::::::::: www.CMNSOFT.com ::::::::::::::::::::

Çevrimdışı sanalboq

  • Delphi 2 Level 3
  • ***
  • İleti: 73
  • Rep: +0/-0
Ynt: Internet - HTML'den resim linklerini almak
« Yanıtla #1 : 06 Haziran 2007 17:59:45 »
bende sözdizimi hatası verdi bu neden kaynaklanıo olabilir ?

Çevrimdışı Kocaturk

  • Administrator
  • *****
  • İleti: 2.474
  • Rep: +56/-5
  • Cinsiyet: Bay
    • Delphi Dünyası
Ynt: Internet - HTML'den resim linklerini almak
« Yanıtla #2 : 06 Haziran 2007 18:27:02 »
bende sözdizimi hatası verdi bu neden kaynaklanıo olabilir ?

verdiği hatayıda yazarsan iyi olur

Çevrimdışı sadik12

  • Delphi 2 Level 3
  • ***
  • İleti: 79
  • Rep: +0/-1
Ynt: Internet - HTML'den resim linklerini almak
« Yanıtla #3 : 06 Haziran 2008 12:21:54 »
webbrowserdeki resim linklerini nasıl alıcaz bilgin varmı


şimdiden teşekkürler