Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.11.11;
Скачать: CL | DM;

Вниз

HTML текст без тегов используя mshtml.dll   Найти похожие ветки 

 
-=Le][=- ©   (2007-03-03 16:35) [0]

Прога стягивает сайт в переменную string.


var
 Http1: TIdHTTP;
 strRead: string;
 strUrl: string;
...
 strRead := Http1.Get (StrUrl);


Как извлеч текст сайта без тегов используя mshtml.dll?


 
Dmitrij_K   (2007-03-03 21:48) [1]

поищи IHTMLDocument2 на http://forum.vingrad.ru/delphi-activex-com-corba-ole.html


 
-=Le][=- ©   (2007-03-04 13:52) [2]

Cпасибо! Нашол прымеры и составил свой код.

function TFindWebThread.GetHtmlText: string;
var
 doc : IHTMLDocument2;
 v   : Variant;
begin
 v    := VarArrayCreate([0, 0], varVariant);
 v[0] := strRead;
 CoInitialize(nil);
 doc  := CoHTMLDocument.Create as IHTMLDocument2;
 doc.writeln(PSafeArray(TVarData(v).VArray));
 Result:=doc.body.innerText;
 doc.close;
end;


 
Ш-К   (2007-03-05 05:16) [3]

А теперь заюзай эту функцию для стрингов:
"<TABLE><TD><P>1111</P></TD><TD><P>2222</P></TD></TABLE>"и
"<TD><P>1111</P></TD><TD><P>2222</P></TD>";
Посмотри на разницу. А должно одно и то же получаться.


 
-=Le][=- ©   (2007-03-05 09:22) [4]


> А теперь заюзай эту функцию для стрингов:
> "<TABLE><TD><P>1111</P></TD><TD><P>2222</P></TD></TABLE>"и
> "<TD><P>1111</P></TD><TD><P>2222</P></TD>";
> Посмотри на разницу. А должно одно и то же получаться.


Разница есть! И что посоветуешь делать?


 
Ш-К   (2007-03-05 10:40) [5]

Я не знаю. У меня те же проблемы.
Пиши сюда, если найдешь.


 
Ш-К   (2007-03-05 11:06) [6]

Пока залатал так:
S:= StringReplace(S, "<table", "<span", [rfReplaceAll, rfIgnoreCase]);
S:= StringReplace(S, "</table", "</span", [rfReplaceAll, rfIgnoreCase]);


 
Vlad Oshin ©   (2007-03-06 14:22) [7]

procedure TForm1.Button1Click(Sender: TObject);
var
strRead: string;
strUrl: string;

function GetHtmlText: string;
var
doc : IHTMLDocument2;
v   : Variant;
 PersistFile: IPersistFile;
begin
v    := VarArrayCreate([0, 0], varVariant);
v[0] := strRead;
CoInitialize(nil);
doc  := CoHTMLDocument.Create as IHTMLDocument2;
doc.writeln(PSafeArray(TVarData(v).VArray));

PersistFile := Doc as IPersistFile;
PersistFile.save(StringToOleStr("c:\1.txt"), true);


Result:=doc.body.innerText;
doc.close;
end;
begin
strRead := idHttp1.Get ("http://localhost/login.htm");
GetHtmlText;
end;


 
-=Le][=- ©   (2007-03-07 14:59) [8]


> PersistFile := Doc as IPersistFile;
> PersistFile.save(StringToOleStr("c:\1.txt"), true);
>


Зачем в сохранять файл?


 
Vlad Oshin ©   (2007-03-07 16:02) [9]

не знаю
а что не надо?
а вдруг кто спросит, где? А тут ты - а вот:



Страницы: 1 вся ветка

Текущий архив: 2007.11.11;
Скачать: CL | DM;

Наверх




Память: 0.49 MB
Время: 0.025 c
2-1192591433
balepa
2007-10-17 07:23
2007.11.11
Access Violation or Invalide Pointer operation


15-1191840512
allrussia
2007-10-08 14:48
2007.11.11
"Кракозябры" при вставке из буфера


2-1192472919
Elec3C
2007-10-15 22:28
2007.11.11
Проблемка с динамическим массивом


15-1191521154
kalexi
2007-10-04 22:05
2007.11.11
Перехват функций...


3-1183445482
Zik
2007-07-03 10:51
2007.11.11
Сообщения MSSQL