Pokušavam napraviti mali programcic koji ce se kaciti na stranice od narodnih novina te gledati zadnji broj novina. koji je u liknu :
Code:
Sub proba()
If (WebBrowser1.ReadyState = WebBrowserReadyState.Complete) Then
For Each ClientControl As HtmlElement In WebBrowser1.Document.Links
ListBox1.Items.Add(ClientControl.GetAttribute("href"))
Next
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim godina As String
Dim broj As String
If (Not File.Exists("C:\NN\NN.txt")) Then
File.WriteAllText("C:\NN\NN.txt", 1)
End If
Dim tr As IO.TextReader = New IO.StreamReader("C:\NN\NN.txt")
broj = tr.ReadToEnd
Dim god As System.DateTime = System.DateTime.Now
godina = "&Godina=" + god.Year.ToString
WebBrowser1.Navigate("http://narodne-novine.nn.hr/sluzbeni/pregledRezultati.aspx?Broj=" & broj & godina)
tr.Close()
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
ListBox1.Items.Clear()
proba()
End Sub
Sub proba()
If (WebBrowser1.ReadyState = WebBrowserReadyState.Complete) Then
For Each ClientControl As HtmlElement In WebBrowser1.Document.Links
ListBox1.Items.Add(ClientControl.GetAttribute("href"))
Next
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim godina As String
Dim broj As String
If (Not File.Exists("C:\NN\NN.txt")) Then
File.WriteAllText("C:\NN\NN.txt", 1)
End If
Dim tr As IO.TextReader = New IO.StreamReader("C:\NN\NN.txt")
broj = tr.ReadToEnd
Dim god As System.DateTime = System.DateTime.Now
godina = "&Godina=" + god.Year.ToString
WebBrowser1.Navigate("http://narodne-novine.nn.hr/sluzbeni/pregledRezultati.aspx?Broj=" & broj & godina)
tr.Close()
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
ListBox1.Items.Clear()
proba()
End Sub
Ovim gore kodom sam uspio se nakaciti na link sa brojem 1 i godinom 2014.
Pitanje :
Učitavanje zadnjeg broja Narodnih novina koji u body -u ima "href" tag te spremanje istoga unutar NN.txt datoteka npr :
http://narodne-novine.nn.hr/sluzbeni/pregledRezultati.aspx?Broj=15&Godina=2014
Znam da br. 15 postoji te u sebi sarži href tag
ali zato broj : 9900 ne postoji te u sebi ima samo jedan href tag
http://narodne-novine.nn.hr/sluzbeni/pregledRezultati.aspx?Broj=9900&Godina=2014
Kako riješiti zapis sadnjeg broj-a iz url-a u txt file ?