Dim DataTable_Scraping As New DataTable DataGridView1.DataSource = DataTable_Scraping
Private Async Sub WebView2_NavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs) Handles WebView21.NavigationCompleted Dim js As New System.Text.StringBuilder js.AppendLine("const hyou=[];let i=0;") js.AppendLine("var TrElems = document.getElementsByClassName('Tableが含まれるクラス名')[0].getElementsByTagName('tr');") js.AppendLine("Array.prototype.forEach.call(TrElems, function(TrElem) {") js.AppendLine(" hyou.push([]);") js.AppendLine(" var TdElems = TrElem.getElementsByTagName('td');") js.AppendLine(" Array.prototype.forEach.call(TdElems, function(TdElem) {") js.AppendLine(" hyou[i].push(TdElem.textContent);") js.AppendLine(" });") js.AppendLine(" i=i+1;") js.AppendLine("});") js.AppendLine("return hyou;")
DataTable_Scraping = Await WebView21.ExecuteScriptAsync(js.ToString()) '読み込み結果を判定 If e.IsSuccess Then ‘ここで次のページへの移動用の要素をクリックしている。動作確認済み ‘getElementsByClassName('****')の要素数が1の場合は、終わり Await WebView21.ExecuteScriptAsync( "document.getElementsByClassName('****')[1].getElementsByTagName('a')[0].click();") Else Console.WriteLine(e.WebErrorStatus) End If End Sub