如何在C ++构建器中访问网页页面元素 [英] How do I access webpage page elements in C++ builder

查看:115
本文介绍了如何在C ++构建器中访问网页页面元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在RAD Studio Xe8 C ++构建器中使用TWebBrowser时遇到了麻烦。



我无法弄清楚如何访问网页上的元素,比如读取输入字段的内容...

我发现的所有相关示例都在Delphi中,我尝试使用此WebBrowser1-> Document-> getElementByID(input1)

但是该方法不是Document的成员,类型是IDispatch,我不知道那是什么,我可以通过这个IDispatch类访问我正在寻找的方法吗?或者我走错了路?



任何简单的代码都会很好。

提前谢谢



我的尝试:



Hi, I'm having trouble working with TWebBrowser in RAD Studio Xe8 C++ builder.

I can't figure out how to access elements on a webpage, like reading the content of an input field...
All the relevant examples that I've found are in Delp I tried using this WebBrowser1->Document->getElementByID("input1")
But the method isn't a member of Document which type is IDispatch and I don't know what that is, Can I access the methods that I'm looking for through this IDispatch class? or am I on the wrong path?

Any simple code would be nice.
Thank you in advance

What I have tried:

WebBrowser1->Document->getElementByID("input1")

IHTMLDocument2 *Doc = dynamic_cast<IHTMLDocument2 *>(WebBrowser1->Document);

IHTMLDocument2 *Doc;
Doc=(IHTMLDocument2)WebBrowser1->Document;

推荐答案

您必须获取正确的接口才能调用该方法。



这应该有效,但是应该使用正确的处理程序访问网站,比如OnDocumentComplete。



看起来这里有一些帮助代码来理解文档和访问其内容。 (我没有找到更好的东西)
You must acquire the correct interface to call the method.

This should work, but should access the website at the correct handler, like OnDocumentComplete.

Look like here is some helping code to understand the Document and the access to its content. (I didnt find anything better)


这篇关于如何在C ++构建器中访问网页页面元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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