i = -1 Try For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div") If Element.GetAttribute("className") = "col-9" Then For Each Element1 As HtmlElement In Element.GetElementsByTagName("div") If Element1.GetAttribute("className") = "p24_content" Then i = i + 1 'DataGridView1.Rows.Add() For Each Element2 As HtmlElement In Element1.GetElementsByTagName("span") If Element2.GetAttribute("className") = "p24_address" Then DataGridView1.Rows(i).Cells(8).Value = Element2.InnerText End If Next End If If Element1.GetAttribute("className") = "p24_price" Then DataGridView1.Rows(i).Cells(1).Value = Element1.InnerText End If If Element1.GetAttribute("className") = "p24_description" Then Dim Stringer As String = Element1.InnerText Dim tokens = Stringer.Substring(Stringer.LastIndexOf(" in ") + 4) DataGridView1.Rows(i).Cells(0).Value = tokens End If If Element1.GetAttribute("className") = "p24_icons" Then 'Dim Variable1 As String = Element1.InnerText For Each o As HtmlElement In Element1.All If o.GetAttribute("title") = "Erf Size" Then ' ListBox2.Items.Add("Erf Size:" & vbTab & vbTab & o.InnerText) DataGridView1.Rows(i).Cells(3).Value = o.InnerText End If If o.GetAttribute("title") = "Floor Size" Then ' ListBox2.Items.Add("Floor Size:" & vbTab & o.InnerText) DataGridView1.Rows(i).Cells(2).Value = o.InnerText End If ' Add bedrooms If o.GetAttribute("title") = "Bedrooms" Then ' ListBox2.Items.Add("Bedrooms:" & vbTab & o.InnerText) DataGridView1.Rows(i).Cells(4).Value = o.InnerText End If If o.GetAttribute("title") = "Bathrooms" Then ' ListBox2.Items.Add("Bathrooms:" & vbTab & o.InnerText) DataGridView1.Rows(i).Cells(5).Value = o.InnerText End If If o.GetAttribute("title") = "Parking Spaces" Then ' ListBox2.Items.Add("Parking/Garages:" & vbTab & o.InnerText) DataGridView1.Rows(i).Cells(6).Value = o.InnerText End If ' Next End If Next End If Next Catch ex As Exception MessageBox.Show("First Column - 2") End Try Try For Each Element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div") If Element.GetAttribute("className") = "p24_regularTile js_rollover_container " Then For Each Element1 As HtmlElement In Element.GetElementsByTagName("a") If Element1.GetAttribute("href") IsNot Nothing Then DataGridView1.Rows(i).Cells(8).Value = Element1.InnerText End If Next End If Next Catch ex As Exception MessageBox.Show("First Column - 3") End Try ' Colum 2 Try For Each Element5 As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div") If Element5.GetAttribute("className") = "js_listingResultsContainer" Then For Each Element6 As HtmlElement In Element5.GetElementsByTagName("span") If Element6.GetAttribute("className") = "p24_content" Then i = i + 1 DataGridView1.Rows.Add() For Each Element7 As HtmlElement In Element6.All If Element7.GetAttribute("itemprop") = "offers" Then ' Add location Dim Stringer As String = Element7.InnerHtml Stringer = Stringer.Replace("""", "").Replace(vbCr, "").Replace(vbLf, "") Dim tokens = Stringer.Substring(Stringer.LastIndexOf("p24_location") + 1) Dim SplitLine As String() SplitLine = Split(tokens, "") Dim split2 As String = SplitLine(0) split2 = split2.Replace("24_location >", "") DataGridView1.Rows(i).Cells(0).Value = split2 End If For Each Element8 As HtmlElement In Element5.GetElementsByTagName("div") If Element7.GetAttribute("className") = "p24_address" Then DataGridView1.Rows(i).Cells(8).Value = Element7.InnerText End If Next Next For Each o As HtmlElement In Element6.GetElementsByTagName("span") If o.GetAttribute("class") = "p24_location" Then 'DataGridView1.Rows(i).Cells(0).Value = o.InnerText End If If o.GetAttribute("itemprop") = "price" Then DataGridView1.Rows(i).Cells(1).Value = o.InnerText End If If o.GetAttribute("title") = "Floor Size" Then DataGridView1.Rows(i).Cells(2).Value = o.InnerText End If If o.GetAttribute("title") = "Erf Size" Then DataGridView1.Rows(i).Cells(3).Value = o.InnerText End If If o.GetAttribute("title") = "Bedrooms" Then DataGridView1.Rows(i).Cells(4).Value = o.InnerText End If If o.GetAttribute("title") = "Bathrooms" Then DataGridView1.Rows(i).Cells(5).Value = o.InnerText End If If o.GetAttribute("title") = "Parking Spaces" Then DataGridView1.Rows(i).Cells(6).Value = o.InnerText End If Next End If Next For Each Element6 As HtmlElement In Element5.GetElementsByTagName("a") If Element6.GetAttribute("className") = "p24_content" Then i = i + 1 DataGridView1.Rows.Add() For Each Element7 As HtmlElement In Element6.All If Element7.GetAttribute("itemprop") = "offers" Then ' Add location Dim Stringer As String = Element7.InnerHtml Stringer = Stringer.Replace("""", "").Replace(vbCr, "").Replace(vbLf, "") Dim tokens = Stringer.Substring(Stringer.LastIndexOf("p24_location") + 1) Dim SplitLine As String() SplitLine = Split(tokens, "") Dim split2 As String = SplitLine(0) split2 = split2.Replace("24_location >", "") DataGridView1.Rows(i).Cells(0).Value = split2 End If For Each Element8 As HtmlElement In Element5.GetElementsByTagName("div") If Element7.GetAttribute("className") = "p24_address" Then DataGridView1.Rows(i).Cells(8).Value = Element7.InnerText End If Next Next For Each o As HtmlElement In Element6.GetElementsByTagName("span") If o.GetAttribute("class") = "p24_location" Then 'DataGridView1.Rows(i).Cells(0).Value = o.InnerText End If If o.GetAttribute("itemprop") = "price" Then DataGridView1.Rows(i).Cells(1).Value = o.InnerText End If If o.GetAttribute("title") = "Floor Size" Then DataGridView1.Rows(i).Cells(2).Value = o.InnerText End If If o.GetAttribute("title") = "Erf Size" Then DataGridView1.Rows(i).Cells(3).Value = o.InnerText End If If o.GetAttribute("title") = "Bedrooms" Then DataGridView1.Rows(i).Cells(4).Value = o.InnerText End If If o.GetAttribute("title") = "Bathrooms" Then DataGridView1.Rows(i).Cells(5).Value = o.InnerText End If If o.GetAttribute("title") = "Parking Spaces" Then DataGridView1.Rows(i).Cells(6).Value = o.InnerText End If Next End If Next For Each Element6 As HtmlElement In Element5.GetElementsByTagName("span") If Element6.GetAttribute("className") = "p24_content" Then i = i + 1 DataGridView1.Rows.Add() For Each Element7 As HtmlElement In Element6.All If Element7.GetAttribute("itemprop") = "offers" Then ' Add location Dim Stringer As String = Element7.InnerHtml Stringer = Stringer.Replace("""", "").Replace(vbCr, "").Replace(vbLf, "") Dim tokens = Stringer.Substring(Stringer.LastIndexOf("p24_location") + 1) Dim SplitLine As String() SplitLine = Split(tokens, "") Dim split2 As String = SplitLine(0) split2 = split2.Replace("24_location >", "") DataGridView1.Rows(i).Cells(0).Value = split2 End If For Each Element8 As HtmlElement In Element5.GetElementsByTagName("div") If Element7.GetAttribute("className") = "p24_address" Then DataGridView1.Rows(i).Cells(8).Value = Element7.InnerText End If Next Next For Each o As HtmlElement In Element6.GetElementsByTagName("span") If o.GetAttribute("class") = "p24_location" Then 'DataGridView1.Rows(i).Cells(0).Value = o.InnerText End If If o.GetAttribute("itemprop") = "price" Then DataGridView1.Rows(i).Cells(1).Value = o.InnerText End If If o.GetAttribute("title") = "Floor Size" Then DataGridView1.Rows(i).Cells(2).Value = o.InnerText End If If o.GetAttribute("title") = "Erf Size" Then DataGridView1.Rows(i).Cells(3).Value = o.InnerText End If If o.GetAttribute("title") = "Bedrooms" Then DataGridView1.Rows(i).Cells(4).Value = o.InnerText End If If o.GetAttribute("title") = "Bathrooms" Then DataGridView1.Rows(i).Cells(5).Value = o.InnerText End If If o.GetAttribute("title") = "Parking Spaces" Then DataGridView1.Rows(i).Cells(6).Value = o.InnerText End If Next End If Next For Each Element6 As HtmlElement In Element5.GetElementsByTagName("a") If Element6.GetAttribute("className") = "p24_content" Then i = i + 1 DataGridView1.Rows.Add() For Each Element7 As HtmlElement In Element6.All If Element7.GetAttribute("itemprop") = "offers" Then ' Add location Dim Stringer As String = Element7.InnerHtml Stringer = Stringer.Replace("""", "").Replace(vbCr, "").Replace(vbLf, "") Dim tokens = Stringer.Substring(Stringer.LastIndexOf("p24_location") + 1) Dim SplitLine As String() SplitLine = Split(tokens, "") Dim split2 As String = SplitLine(0) split2 = split2.Replace("24_location >", "") DataGridView1.Rows(i).Cells(0).Value = split2 End If For Each Element8 As HtmlElement In Element5.GetElementsByTagName("div") If Element7.GetAttribute("className") = "p24_address" Then DataGridView1.Rows(i).Cells(8).Value = Element7.InnerText End If Next Next For Each o As HtmlElement In Element6.GetElementsByTagName("span") If o.GetAttribute("class") = "p24_location" Then 'DataGridView1.Rows(i).Cells(0).Value = o.InnerText End If If o.GetAttribute("itemprop") = "price" Then DataGridView1.Rows(i).Cells(1).Value = o.InnerText End If If o.GetAttribute("title") = "Floor Size" Then DataGridView1.Rows(i).Cells(2).Value = o.InnerText End If If o.GetAttribute("title") = "Erf Size" Then DataGridView1.Rows(i).Cells(3).Value = o.InnerText End If If o.GetAttribute("title") = "Bedrooms" Then DataGridView1.Rows(i).Cells(4).Value = o.InnerText End If If o.GetAttribute("title") = "Bathrooms" Then DataGridView1.Rows(i).Cells(5).Value = o.InnerText End If If o.GetAttribute("title") = "Parking Spaces" Then DataGridView1.Rows(i).Cells(6).Value = o.InnerText End If Next End If Next End If Next Catch ex As Exception MessageBox.Show("Second Column") End Try For E2 = 0 To DataGridView1.Rows.Count - 1 If DataGridView1.Rows(E2).Cells(1).Value = Nothing Then DataGridView1.Rows(E2).Cells(1).Value = "POA" End If Next ' Delete first promo ad If DataGridView1.Rows.Count > 0 Then DataGridView1.Rows.RemoveAt(0) End If ' Delete duplicate rows For intI = DataGridView1.Rows.Count - 1 To 0 Step -1 For intJ = intI - 1 To 0 Step -1 If DataGridView1.Rows(intI).Cells(0).Value = DataGridView1.Rows(intJ).Cells(0).Value AndAlso DataGridView1.Rows(intI).Cells(1).Value = DataGridView1.Rows(intJ).Cells(1).Value Then DataGridView1.Rows.RemoveAt(intI) Exit For End If Next Next RunThrough() End If 'remove duplicates from listbox Dim items(ListBox1.Items.Count - 1) As Object ListBox1.Items.CopyTo(items, 0) ListBox1.Items.Clear() ListBox1.Items.AddRange(items.AsEnumerable().Distinct().ToArray()) If ListBox1.Items.Count > 0 Then ListBox1.Items.RemoveAt(0) 'ListBox1.Items.RemoveAt(1) End If ' add listbox to datagrid For index As Integer = 0 To 15 Try For inti = DataGridView1.Rows.Count - 1 To 0 Step -1 For intJ = inti - 1 To 0 Step -1 Dim ar As String = DataGridView1.Rows(intJ).Cells(7).Value Dim Line As String = DataGridView1.Rows(intJ).Cells(0).Value Dim List As String = ListBox1.Items(inti) Line = Line.Replace(" ", "-").ToLower Dim Line2 As Regex = New Regex(Line) If Line2.IsMatch(List) Then If DataGridView1.Rows(intJ).Cells(7).Value = Nothing Then DataGridView1.Rows(intJ).Cells(7).Value = List End If Exit For End If Next Next Catch ex As Exception End Try 'Remove duplicates from listbox Try For intI = ListBox1.Items.Count - 1 To 0 Step -1 For intJ = intI - 1 To 0 Step -1 Dim List As String = ListBox1.Items(intI) Dim ar As String = DataGridView1.Rows(intJ).Cells(7).Value If List = ar Then ListBox1.Items.RemoveAt(intI) Exit For End If Next Next Catch ex As Exception End Try Next Dim counter As Integer = 0 For E1 = 0 To DataGridView1.Rows.Count - 1 counter = counter + 1 Next For index As Integer = counter To 11 DataGridView1.Rows.Add()