누군가를 도와 줄 수 있기를 희망합니다. 민첩성 팩을 사용하여 테이블에서 데이터를 추출하고이를 데이터 그리드에 배치합니다 (데이터 그리드는 중요하지 않습니다. 필자가 추출 작업을 하는지를보기 위해 중요합니다). 어쨌든 테이블 축소판 그림의 첫 번째 열에 포함되어 있습니다. 아래의 코드를 사용하여 모든 텍스트를 추출 할 수 있지만 첫 번째 열에서 이미지를 추출하는 방법을 모르겠다 ... 아무도 도와 줄 수 있습니까?
추신 : 나는 그것으로부터 직접적으로 어떠한 데이터도 추출 할 수 없기 때문에 웹 페이지를 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
아마도 이미지는 다음과 같습니다.
<img src="whatever.jpg"/>
마크 업에서, 맞지?
HAP을 사용하면 이미지 노드를
... .SelectNodes("./img")
그리고 경로 :
... .Attributes("src").Value()
거기에서, 나는 당신이 실제로 이와 같은 HTTP 요청을 수행 할 수있게 해주는 특별한 HAP 기능을 알지 못한다. 그래서 당신은 그것을위한 WebClient 를 원할 것이다.
Dim wc as new WebClient
wc.DownloadFile(StringContainingThatSrcValue, PathToSaveFileTo)
HTH!