国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

如何獲取本地HTML文件的標題,超級鏈接

2019-11-18 17:56:53
字體:
來源:轉載
供稿:網友

本文用于提取本地網頁的標簽元素如<TITLE></TITLE>,<IMG>,<A></A>...的內容,非常實用于批量文件的操作,這是按一般文件進行文本查找替換無法比擬的,,而這是使用TWEBBROWSER控件無法做到的。類似的,
你可以把本地的HTML文件轉換成MHT文件(這是個大家覺得很棘手的問題,本人已經搞定)。

//uses activex,mshtml

function Html_GetTitleFromFile(const HtmlFile:TFileName;var FileTitle:String):Boolean;
var
Idoc     : IHtmlDocument2;
//ElementGroup : IhtmlElementCollection;
//HtmlItem: IHTMLElement;
PersistFile: ipersistFile;
begin
Result:=False;
if not fileexists(HtmlFile) then
exit;
  FileTitle:='';

  try
       Idoc := CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
       PersistFile := IDoc as IPersistFile;
       if PersistFile.Load(StringToOleStr(HTMLFile),1)<>S_OK then
       exit;
       IDoc.designMode := 'on';  //This will disable script execution.
    {   while IDoc.readyState <> 'complete' do  //if it dead here,how to do it?
       begin
       application.PRocessMessages;
       end;
    }
    //   Showmessage(IDoc.readyState);
       Application.ProcessMessages;
       sleep(1000);
    //   Showmessage(IDoc.readyState);
       if IDoc.readyState<>'complete' then
       begin
       Application.ProcessMessages;
       sleep(1000);
       end;
       if IDoc.readyState<>'complete' then
       begin
       IDoc:=nil;
       Result:=False;
       exit;
       end;
        Result:=True;
       FileTitle:=IDoc.title;
       {  //This code also works
       ElementGroup:=IDoc.all.tags('TITLE') As IhtmlElementCollection;
       HtmlItem:=ElementGroup.item(0,0) As IHtmlElement;
       FileTitle:=HtmlItem.innerText;
       }

   finally
        IDoc := nil;
   end;
end;



上一篇:BPCS系統現金流量分析工具開發日志

下一篇:建立自己的csdn知識管理庫(1)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
學習交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網友關注

主站蜘蛛池模板: 娄底市| 乡城县| 凤台县| 股票| 松溪县| 遵义县| 疏勒县| 安龙县| 阳东县| 温州市| 绿春县| 武冈市| 临洮县| 罗源县| 綦江县| 富川| 社会| 阿城市| 石狮市| 彰武县| 喀喇沁旗| 中阳县| 增城市| 洛南县| 洞头县| 北宁市| 米林县| 枣庄市| 桃江县| 屏东县| 奉化市| 长岭县| 沾益县| 佛教| 顺昌县| 邢台市| 竹山县| 通州区| 江口县| 永顺县| 邵阳市|