HOW TO leverage HTMLDocument, instend of IHTMLDocument2

weixin_38061331 2016-06-04 12:36:40
HI GUYS, 
NOW WITH C#, I got some problem here , pls help me out . 
I wanna use the "getElementsByTagName" as what i did in javascript , to fetch the htmlElements , then I might inspect and kick off some action of it like click();
but with below code I cannot leverage to the "getElementsByTagName" func, this func is only available in "System.Windows.Forms.HTMLDocument" Class .  


could u hele me to translate the "getIHTMLDocument2ByUrl" func to "getHTMLDocumentByUrl" ?



public mshtml.IHTMLDocument2 getIHTMLDocument2ByUrl(string url)
        {
            SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
            foreach (SHDocVw.InternetExplorer ie in shellWindows)
            {
                string filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
                if (filename.Equals("iexplore") && ie.LocationURL == url)
                {
                    return ie.Document as mshtml.IHTMLDocument2;
                }
            }
            return null;
        }



 
...全文
16 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复

476

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧