我需要从this web page得到一些文字。我想用我的计划中的交易饲料来分析市场情绪。来自网页的文字
我用浏览器控件和get元素命令,但它不工作。问题是,无论何时我的浏览器开始打开页面,我都会收到Java脚本错误。
我试图与DOM但目前看来,我不很明白我需要做的:) 下面是代码:
Dim code As String
Using client As New WebClient
code = client.DownloadString("http://openbook.etoro.com/ahanit/#/profile/Trades/")
End Using
Dim htmlDocument As IHTMLDocument2 = New HTMLDocument(code)
htmlDocument.write(htmlDocument)
Dim allElements As IHTMLElementCollection = htmlDocument.body.all
Dim allid As IHTMLElementCollection = allElements.tags("id")
Dim element As IHTMLElement
For Each element In allid
element.title = element.innerText
MsgBox(element.innerText)
Next
更新:所以我尝试了HTML敏捷包,如建议评论,我再次卡在这个代码
Dim plain As String = String.Empty
Dim htmldoc As New HtmlAgilityPack.HtmlDocument
htmldoc.LoadHtml("http://openbook.etoro.com/ahanit/#/profile/Trades/")
Dim goodnods As HtmlAgilityPack.HtmlNodeCollection = htmldoc.DocumentNode.SelectNodes("THE PROBLEM")
For Each node In goodnods
TextBox1.Text = htmldoc.DocumentNode.InnerText
Next
任何意见什么现在?
好吧我想我知道问题是什么,我需要的div是隐藏的,它没有加载,当我加载网页只是源代码。有人知道如何加载所有隐藏的div?
这是我的新代码
Dim doc As New HtmlAgilityPack.HtmlDocument
Dim web As New HtmlWeb
doc = web.Load("http://openbook.etoro.com/ahanit/#/profile/Trades/")
Dim nodes As HtmlNode = doc.GetElementbyId("feed-items")
Dim id As String = nodes.WriteTo()
TextBox1.Text = TextBox1.Text & vbCrLf & id
你试过HTML敏捷ACK:http://htmlagilitypack.codeplex.com/ – Shoban 2012-04-16 15:30:01
谢谢Shoban,但什么也没有,我知道:)我没有太多EXP用vb所有上面的代码是3天谷歌搜索的结果,仍然知道在视线内:) – user1336635 2012-04-16 16:07:20
shoban如果你现在如何工作plzz一些建议:) – user1336635 2012-04-17 10:22:52