这里推荐一个不错的DLL 叫HtmlAgilityPack.dll,它不基于mshtml,轻松解析HTML代码,这对做采集软件来说是很不错的选择,使用非常简单:
--------------------------------------------------------------------------------
Dim wc As WebClient = New WebClient
Dim ms As MemoryStream = New MemoryStream(wc.DownloadData(url))
'预读HTML
Dim hdoc As HtmlDocument = New HtmlDocument
hdoc.Load(ms, Encoding.UTF8)
'股票编号
arr(0) = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[1]/div[3]/div[2]/div[1]/div[1]").InnerText
--------------------------------------------------------------------------------
其中 /html[1]/body[1]/div[1]/div[1]/div[3]/div[2]/div[1]/div[1] 是你要采集的xPath,这个有点像DOMhtml,HtmlAgilityPack 也提供了相应的工具软件来获取这个值,但似乎开发者似乎不怎么了解winform,软件容易崩溃...
--------------------------------------------------------------------------------
Dim wc As WebClient = New WebClient
Dim ms As MemoryStream = New MemoryStream(wc.DownloadData(url))
'预读HTML
Dim hdoc As HtmlDocument = New HtmlDocument
hdoc.Load(ms, Encoding.UTF8)
'股票编号
arr(0) = hdoc.DocumentNode.SelectSingleNode("/html[1]/body[1]/div[1]/div[1]/div[3]/div[2]/div[1]/div[1]").InnerText
--------------------------------------------------------------------------------
其中 /html[1]/body[1]/div[1]/div[1]/div[3]/div[2]/div[1]/div[1] 是你要采集的xPath,这个有点像DOMhtml,HtmlAgilityPack 也提供了相应的工具软件来获取这个值,但似乎开发者似乎不怎么了解winform,软件容易崩溃...