以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  这个错误怎么解决  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=72071)

--  作者:Fotable
--  发布时间:2015/7/22 22:37:00
--  这个错误怎么解决

Dim ObjIE As Object  = CreateObject("internetexplorer.application")
ObjIE.Navigate("url" )
Do While objie.ReadyState <> 4
    Application.DoEvents
Loop
Dim neirong As System.Windows.Forms.HtmlElement
neirong = ObjIE.Document.getelementbyid("js_content")

 

Dim web As System.Windows.Forms.WebBrowser = e.Form.Controls("WebBrowser1").BaseControl
web.Document.window.Frames(0).Document.body.Innerhtml = neirong.Innerhtml

 

运行报错

无法将类型为“System.__ComObject”的 COM 对象强制转换为类类型“System.Windows.Forms.HtmlElement”。表示 COM 组件的类型实例不能强制转换为不表示 COM 组件的类型;不过,只要基础 COM 组件支持对接口 IID 的 QueryInterface 调用,就能将这些实例强制转换为接口。


--  作者:大红袍
--  发布时间:2015/7/22 22:40:00
--  

 用webbrowser就行了,参考奥迪吗

 

Dim web As New System.Windows.Forms.WebBrowser()
web.Navigate("http://vip.stock.finance.sina.com.cn/mkt/#all_forex")
Do Until web.ReadyState = 4
    Application.DoEvents
Loop
MessageBox.Show("等待数据加载完成")

Dim elems As object = web.Document.GetElementById("list_amount_ctrl").GetElementsByTagName("a")
For Each elem As object In elems
    If elem.InnerText = "80" Then
        elem.InvokeMember("click")
    End If
Next

elems = web.Document.GetElementById("tbl_wrap").GetElementsByTagName("tr")
MessageBox.Show("共获取 " & elems.count-1 & " 条数据")


--  作者:Fotable
--  发布时间:2015/7/22 23:51:00
--  

Dim web2 As System.Windows.Forms.WebBrowser = e.Form.Controls("WebBrowser2").BaseControl
web2.navigate( "url" )
Do While web2.ReadyState <> 4
    Application.DoEvents
Loop


Dim web As System.Windows.Forms.WebBrowser = e.Form.Controls("WebBrowser1").BaseControl
web.Document.window.Frames(0).Document.body.Innerhtml = neirong.Innerhtml \'

 

修改成这样 同样报错


--  作者:Fotable
--  发布时间:2015/7/22 23:54:00
--  
谢谢 可以了