Показать сообщение отдельно
  #5  
Старый 06.11.2011, 08:36
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

Код:
uses
  MSHTML,

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    Memo1: TMemo;
    Memo2: TMemo;
    procedure FormCreate(Sender: TObject);

procedure TForm1.FormCreate(Sender: TObject);
var
  document: OleVariant;
  HTMLDocument: IHTMLDocument3;
  HTMLElementCollection: IHTMLElementCollection;
  i: Integer;
  HTMLElement: IHTMLElement;
  HTMLElementCollection2: IHTMLElementCollection;
  j: Integer;
begin
  Memo1.Lines.LoadFromFile('Project1.htm');
  WebBrowser1.Navigate('about:blank');
  while WebBrowser1.ReadyState<READYSTATE_INTERACTIVE do
    Application.ProcessMessages;
  document:=WebBrowser1.Document;
  document.clear;
  document.open;
  document.write(Memo1.Text);
  document.close;
  HTMLDocument:=WebBrowser1.Document as IHTMLDocument3;
  HTMLElementCollection:=HTMLDocument.getElementsByTagName('ul');
  for i:=0 to HTMLElementCollection.length-1 do
  begin
    HTMLElement:=HTMLElementCollection.item(i, 0) as IHTMLElement;
    Memo2.Lines.Add('--'+HTMLElement.getAttribute('data-property', 0)+'--');
    HTMLElementCollection2:=HTMLElement.children as IHTMLElementCollection;
    for j:=0 to HTMLElementCollection2.length-1 do
      Memo2.Lines.Add((HTMLElementCollection2.item(j, 0) as IHTMLElement).innerText);
  end;
end;

http://data.cod.ru/130989
http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx
__________________
Пишу программы за еду.
__________________
Ответить с цитированием