🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.web
Article #944

Re: CPPWebBrowser

#944
From: Hans Galema
Date: Tue, 14 Feb 2006 11:07
46 lines
2225 bytes
Adam wrote:
> I mean how to get all links within the web pages. Thanks.

To get and show the links from the page displayed by TCppWebBrowser:

void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
   AnsiString AllLinks = "";

   IHTMLDocument2 *HTMLDoc = NULL;

   if(SUCCEEDED(CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&HTMLDoc)))
      {
      IHTMLElementCollection *pAll = NULL;

      if(SUCCEEDED(HTMLDoc->get_links(&pAll)))
         {
         long collSize;
         pAll->get_length(&collSize);
         IDispatch* id;
         VARIANT one;
         for( int idx = 0; idx < collSize; idx++)
            {
            one.vt = VT_UINT;
            one.lVal = idx;
            VARIANT two = {0};
            pAll->item(one,two,&id);
            IHTMLElement* pElem = NULL;
            id->QueryInterface( IID_IHTMLElement, (LPVOID*)&pElem );
            BSTR bstr = NULL;
            pElem->toString(&bstr);

            AllLinks += bstr;
            AllLinks += "\n";
            }
	
	pAll->Release();
         }

      HTMLDoc->Release();
      }

   ShowMessage ( AllLinks );
}

Hans.
Technical Details
Message-ID: <43f1b9bf$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43ec66c3@newsgroups.borland.com> <43f08297$1@newsgroups.borland.com> <43f120ab@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,6040e84eda1651db
X-Google-Attributes: gidfeeec,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 14 Feb 2006 12:07:32 +0100
From: Hans Galema <notused@notused.nl>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.internet.web
Subject: Re: CPPWebBrowser
References: <43ec66c3@newsgroups.borland.com> <43f08297$1@newsgroups.borland.com> <43f120ab@newsgroups.borland.com>
In-Reply-To: <43f120ab@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 145.98.201.248
Message-ID: <43f1b9bf$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1139915199 145.98.201.248 (14 Feb 2006 03:06:39 -0700)
Lines: 46
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!proxad.net!194.117.148.138.MISMATCH!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail