希望有人可以提供幫助,因為我花了很多時間試圖解決這個問題。我正在使用敏捷包從表中提取數據並將其放入數據網格中(數據網格並不重要,我只是使用它來查看提取是否有效)。無論如何,在表的第一列中包含縮略圖。我可以使用下面的代碼提取所有文本,但我不知道如何從第一列中提取圖像...任何人都可以幫忙嗎?
PS我已將網頁保存為MHL文件,因為無法直接從中提取任何數據 - 我認為這與網站安全/憑據有關。不知道我是否讓自己變得更容易或更難。
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
' '' original cods ***************************************
Dim Web As New HtmlAgilityPack.HtmlWeb
Dim Doc As New HtmlAgilityPack.HtmlDocument
Dim RowCount As Integer = 1
' Doc = Web.Load("https://firefly.cardinalnewman.ac.uk/home/my")
Doc.Load("E:\table.mht")
Dim tables As HtmlAgilityPack.HtmlNodeCollection = Doc.DocumentNode.SelectNodes("//table")
Dim img As HtmlAgilityPack.HtmlNodeCollection = Doc.DocumentNode.SelectNodes("//table")
Dim Links As HtmlAgilityPack.HtmlNodeCollection = Doc.DocumentNode.SelectNodes("//table")
Dim rows As HtmlAgilityPack.HtmlNodeCollection = tables(0).SelectNodes("//*[@id=HomeMyStudents]")
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[1]")
RowCount = RowCount + 1
DGV.Rows.Add(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing)
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[2]")
RowCount = RowCount + 1
' DGV.Rows(RowCount).Cells(1).Value = somehow insert image
' this is the section where I need to grab the image in each cell and either save or place in my datagrid
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[3]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(2).Value = table.InnerText
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[4]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(3).Value = table.InnerText
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[5]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(4).Value = table.InnerText
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[6]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(5).Value = table.InnerText
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[7]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(6).Value = table.InnerText
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[8]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(7).Value = table.InnerText
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[9]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(8).Value = table.InnerText
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[10]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(9).Value = table.InnerText
Next
RowCount = 0
For Each table As HtmlAgilityPack.HtmlNode In Doc.DocumentNode.SelectNodes("//*[@id='HomeMyStudents']/tbody/tr['RowCount']/td[11]")
RowCount = RowCount + 1
DGV.Rows(RowCount).Cells(10).Value = table.InnerText
Next
End Sub