Ausführen, bis URL ändert

  • VB.NET

Es gibt 25 Antworten in diesem Thema. Der letzte Beitrag () ist von SeriTools.

    VB.NET-Quellcode

    1. Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated
    2. Dim Quelltext As String = WebBrowser1.DocumentText
    3. Dim Downloadlink As MatchCollection = Regex.Matches(Quelltext, "><b>Click to download (?<Downloadlink>.+?).txt</b></a></p>")
    4. For Each match As Match In Regex.Matches(Quelltext, "><b>Click to download (?<Downloadlink>.+?).txt</b></a></p>", RegexOptions.Singleline)
    5. Dim Downloadlink1 As String = (match.Groups("Downloadlink").Value)
    6. Downloadlink2 = Downloadlink1
    7. Next
    8. Dim Link As String = ("www.gpsvisualizer.com/display/convert/" & Downloadlink2 & ".txt")
    9. WebBrowser1.Navigate(Link)
    10. While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
    11. Application.DoEvents()
    12. End While
    13. RichTextBox1.Text = WebBrowser1.DocumentText
    14. Dim Text As String = RichTextBox1.Text
    15. Dim RT0 As String = Text.Replace("<!DOCTYPE HTML PUBLIC " & Chr(34) & "-//W3C//DTD HTML 4.0 Transitional//EN" & Chr(34) & ">", "")
    16. Dim RT1 As String = RT0.Replace("<HTML><HEAD>", "")
    17. Dim RT2 As String = RT1.Replace("<META content=" & Chr(34) & "text/html; charset=utf-8" & Chr(34) & " http-equiv=Content-", "")
    18. Dim RT3 As String = RT2.Replace("Type></HEAD>", "")
    19. Dim RT4 As String = RT3.Replace("<BODY><PRE>type time latitude longitude sym name desc url urlname", "")
    20. RichTextBox1.Text = RT4
    21. Dim type As MatchCollection = Regex.Matches(RT4, "Geocache (?<Name>.+?) GC")
    22. Dim Nummer As MatchCollection = Regex.Matches(RT4, "GC(?<ID>.+?), placed by ")
    23. For Each match As Match In Regex.Matches(RT4, "Geocache (?<Name>.+?) GC.*?GC(?<ID>.+?), placed by ", RegexOptions.Singleline)
    24. Dim Typ As String = (match.Groups("Name").Value)
    25. Dim Number As String = "GC" & (match.Groups("ID").Value)
    26. dgv.Rows.Add(Typ, Number)
    27. Next
    28. For i = 0 To dgv.Rows.Count - 1
    29. If dgv.Rows(i).Cells(0).Value.ToString.EndsWith("/5)") Then
    30. dgv.Rows(i).Selected = True
    31. Dim ii As String = dgv.Rows(i).Cells(0).Value.ToString
    32. Dim iii As String = dgv.Rows(i).Cells(1).Value.ToString
    33. Drucken.dgv.Rows.Add(ii, iii)
    34. End If
    35. Next
    36. End Sub
    Och man, dein Code ergibt doch garkeinen Sinn? Erstens hast du die While Schleife immernoch drin (Z.18) und zweitens hast du Zeile 16 drin, wodurch eine Endlosschleife entsteht. Wenn eine Seite gerade fertig geladen wurde, lädst du per "navigate()" noch eine, welche, wenn sie fertig ist, wieder das Event auslöst.
    | Keine Fragen per PN oder Skype.
    Überprüfe, ob noch die erste Seite offen ist oder nicht. Mehr möchte ich dir nicht helfen, da könnte ich das Programm ja für dich schreiben.
    Ich rate dir dringend zu einem guten VB.NET-Einsteigerbuch.

    lg SeriTools
    | Keine Fragen per PN oder Skype.