Predmet:čitanje podataka sa internet strane
   
Pokušavam da dobijem određene podatke sa neta. Provera računa kupaca da li su u blokadi ili ne (broj računa i opis). Našao sam kod koji mi dostavi potrebne podatke ali ga stavlja u listview i to u jedan red. Ako ima 5 zapisa biće 10 kolona (2 zapisa po id) ako ima 2 zapisa biće 4 kolona. Pokušao sam sa 2 datagrida i ako ih spojim dobiću ono što želim.
Moje pitanje je da li postoji lakši način da podatke dobijem u formatu koji želim?
primer:
111-1111111111111-11 račun u blokadi
222-2222222222222-22 nije u blokadi
evo koda i print screen
**************************************************
***
Imports System.Net
Imports System.IO
Imports System.Windows.Forms
Imports System.Text.RegularExpressions
Imports System.Xml
Public Class Form1
    Dim ITEM As New ListViewItem
    Dim RacunBR As String = "Račun:"
    Dim Status As String
    Dim Banka As String
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        '
http://www.nbs.rs/...=101811670
        Dim Source As String = New Net.WebClient().DownloadString("
http://www.nbs.rs/...01479056")
        Dim recentSource As String = GetTagContents(Source, "<table class=""main"" width=""100%"">", "</table>")(0)    
        For Each title As String In GetTagContents(recentSource, "<strong>", "</strong>")
            Dim value As String = title
            Dim length As Integer = value.Length
            
            If Not title.Contains("http:") Then
                Dim lvi As New ListViewItem
                lvi.Text = title
                ListView1.Items.Add(lvi)
            End If
            DataGridView1.ColumnCount = 2
            DataGridView1.Columns(0).Name = "RB"
            DataGridView1.Columns(0).Width = 40
            DataGridView1.Columns(1).Name = "Opis"
            DataGridView1.Columns(1).Width = 400
            DataGridView2.ColumnCount = 2
            DataGridView2.Columns(0).Name = "RB"
            DataGridView2.Columns(0).Width = 40
            DataGridView2.Columns(1).Name = "Opis"
            DataGridView2.Columns(1).Width = 400
            If Not title.Contains("http:") And length = 97 Then
                Dim j As Integer = 0
                DataGridView1.Rows.Add(j + DataGridView1.RowCount, title)
            End If
            If Not title.Contains("http:") And length > 35 And length < 51 And Not length = 46 Then
                Dim j As Integer = 0
                DataGridView2.Rows.Add(j + DataGridView2.RowCount, title)
            End If
        Next
    End Sub
    Private Function GetTagContents(ByVal Source As String, ByVal startTag As String, ByVal endTag As String) As List(Of String)
        Dim StringsFound As New List(Of String)
        Dim Index As Integer = Source.IndexOf(startTag) + startTag.Length
        While Index <> startTag.Length - 1
            StringsFound.Add(Source.Substring(Index, Source.IndexOf(endTag, Index) - Index))
            Index = Source.IndexOf(startTag, Index) + startTag.Length
        End While
        Return StringsFound
    End Function
End Class   
   
Prilozi:
   
provera.png
Preuzimanja:240
Velicina datoteke:14.32 KB