与awesominum三夏互动 [英] interacting with awesominum webcontrol
问题描述
您可以找到awesomium三夏HTML元素做进一步的处理。
Can you find HTML elements in awesomium webcontrol to do the further processing?
例如,我可以找到使用华廷必要元素(甚至元素集合)?
For example, I can find necessary element (or even element collection) in Watin using:
Link playButton = myie.ElementOfType<Link>(Find.ById("myid")); // find link (<a>)
Div test = myie.Div(Find.ById("audio")); // find div (<div>)
在发现 - 您可以提取该元素的多个属性
When found - you can extract multiple properties of that element
string classname = playButton.ClassName; // alternatively -> inner text, link, id, class and all bucket of other properties
我要如何做它awesomium ?它有内置的DOM解析器与网站管制? (div的,链接,表格等)
How do I do it in awesomium? Does it have built-in DOM parser to operate with website controls? (divs, links, tables, etc..)
到目前为止,我只能找到JavaScript执行命令的,但是这不是我要找的 ..
So far I could only find javascript execution command but that's not what I'm looking for..
此外,我想知道如何网页的HTML保存到字符串(在awesomium)?
Additionally, I'd like to know how to save webpage's HTML to string (in awesomium)?
string mysite = webControl1.SiteHTML.ToString(); // something like this
// instead of
string mysite = webControl1.ExecuteJavascriptWithResult("document.documentElement.outerHTML").ToString();
编辑:交代
它看起来像awesomium犯规支持HTML元素解析本身,所以我的备份计划如下:
It looks like awesomium doesnt support HTML element parsing natively, so my backup plan is following:
- 开启网页中awesomium
- 抢HTML字符串(目前使用:ExecuteJavascriptWithResult())
- 解析字符串,HTML(目前使用:HTML敏捷包)
- 做什么,我需要做的(寻找元素,收藏等)
- 在awesomium根据上一步结果执行JS命令
- open webpage in awesomium
- grab HTML to string (currently using: ExecuteJavascriptWithResult())
- parse string to HTML (currently using: "HTML Agility pack")
- do what I need to do (find elements, collection, etc.)
- execute JS command in awesomium based on previous step results
所有这一切都将是如果awesomium有DOM支持更容易..但是..好..
All of this would be easier if awesomium had DOM support.. but.. well..
推荐答案
至于在我怎样才能获得HTML的问题,我似乎可以用这样做时,我就遇到了这个问题的半哈克的方式来回顾一下:
With regards to the "How can I get the HTML" question, I seem to recall using a semi-hacky way of doing this when I ran into this problem:
var control = <some awesomium WebControl instance>;
control.SelectAll();
control.CopyHtml();
var html = Clipboard.GetText();
这篇关于与awesominum三夏互动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!