如何使用TIdHTTP中的字符串创建IHTMLDocument2? [英] How do I create an IHTMLDocument2 using a string from TIdHTTP?

查看:244
本文介绍了如何使用TIdHTTP中的字符串创建IHTMLDocument2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了一个 IdHTTP.Get 的URL,我需要搜索HTML标签并提取一些数据。

I download a URL with IdHTTP.Get, and I need to search the HTML tags and extract some data.

如何将 IdHTTP.Get 的字符串转换为 IHTMLDocument2

How I can convert the string that IdHTTP.Get returns into an IHTMLDocument2?

推荐答案

我问了这个问题,我可以找到一个很好的代码:

I Googled this problem and I can find a good code for this:

Idoc := CreateComObject(Class_HTMLDOcument) as IHTMLDocument2;
try
  IDoc.designMode := 'on';
  while IDoc.readyState <> 'complete' do
    Application.ProcessMessages;
  v := VarArrayCreate([0, 0], VarVariant);
  v[0] := MyHTML;
  IDoc.Write(PSafeArray(System.TVarData(v).VArray));
  IDoc.designMode := 'off';
  while IDoc.readyState <> 'complete' do
    Application.ProcessMessages;

  ParseHTML(IDoc);
finally
  IDoc := nil;
end;

关心

这篇关于如何使用TIdHTTP中的字符串创建IHTMLDocument2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆