
06.11.2011, 14:23
|
 |
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
Код:
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Memo1: TMemo;
Memo2: TMemo;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
procedure FormCreate(Sender: TObject);
procedure TForm1.FormCreate(Sender: TObject);
var
document: OleVariant;
HTMLDocument: IHTMLDocument3;
HTMLElementCollection: IHTMLElementCollection;
i: Integer;
HTMLElement: IHTMLElement;
HTMLElementCollection2: IHTMLElementCollection;
j: Integer;
AComboBox: TComboBox;
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)+'--');
if HTMLElement.getAttribute('data-property', 0)='Цвет' then AComboBox:=ComboBox1
else if HTMLElement.getAttribute('data-property', 0)='Размер' then AComboBox:=ComboBox2
else AComboBox:=nil;
HTMLElementCollection2:=HTMLElement.children as IHTMLElementCollection;
for j:=0 to HTMLElementCollection2.length-1 do
begin
if AComboBox<>nil then AComboBox.Items.Add((HTMLElementCollection2.item(j, 0) as IHTMLElement).innerText);
Memo2.Lines.Add((HTMLElementCollection2.item(j, 0) as IHTMLElement).innerText);
end;
end;
end;
__________________
Пишу программы за еду.
__________________
|