Hi,

I guess this interesting small windows application just needs a httpwebrequest and webresponse object. We need to request a web address(which is a google search of football or cricket live - example shown in the screenshot) every 10 minutes using a timer and get the response with score or updates as highlighted and pop up to the user without interuppting his activities. Have attached the screenshot of how what the application would be doing. Can we do this.

Dani AI

Generated

The approach discussed in the thread is workable, but a few practical points shorten development time and reduce breakage. As suggested, periodic HTTP polling is fine for low-frequency updates and, as noted, it can be done. Prefer getting data from an official feed or JSON/RSS API where possible — scraping search-engine result pages is brittle and may violate provider terms. When HTML parsing is required, use a real parser (for example, Html Agility Pack) rather than fragile regexes.

Network work must be off the UI thread (as recommended). A modern pattern is an async HTTP client with cancellation and backoff; parse the response on the worker thread and marshal only UI updates back to the main thread with Invoke/BeginInvoke. Example pattern in VB (parsing left to an implementation function):

Private Async Function PollOnceAsync(url As String) As Task
    Using client As New System.Net.Http.HttpClient()
        client.Timeout = TimeSpan.FromSeconds(15)
        client.DefaultRequestHeaders.UserAgent.ParseAdd("ScorePoller/1.0")
        Dim html As String = Await client.GetStringAsync(url)
        Dim items As List(Of String) = ParseScoreItems(html) ' use HtmlAgilityPack/XPath here
        CheckedListBox1.Invoke(New Action(Sub()
                                             CheckedListBox1.Items.Clear()
                                             For Each it As String In items
                                                 CheckedListBox1.Items.Add(it)
                                             Next
                                         End Sub))
    End Using
End Function

Non‑intrusive notifications work well from the system tray. A NotifyIcon with ShowBalloonTip is simple for brief alerts; for richer notifications on modern Windows, use the toast/notification APIs. Example:

Dim n As New NotifyIcon()
n.Icon = System.Drawing.SystemIcons.Information
n.Visible = True
n.BalloonTipTitle = "Score update"
n.BalloonTipText = "Match: NZ 114/3 — Taylor 23*"
n.ShowBalloonTip(5000)

Troubleshooting and production notes: set reasonable timeouts, log HTML snapshots when parsing fails, handle redirects and encoding, respect robots.txt and provider terms, and implement exponential backoff on repeated failures. For near-real‑time needs, prefer push APIs or WebSocket/SignalR instead of frequent polling. References: Html Agility Pack (https://html-agility-pack.net/) and HttpClient docs (https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient).

Recommended Answers

All 7 Replies

Yes you can.:)

See if this thread helps with extracting data from a website. Should be easy to have the code use HTTP instead of a WebBrowser.

Hi All,

for the below text, I should have four items(there are four >scorecard<) added to my Checkedlistbox1
NZ 114/3(28.2) - LRPL Taylor* 23(27), SB Styris 16(23) | SL yet to bat
Aus 260/6(50.0) | Ind 261/5(47.4) (India won by 5 wickets)
WI 112/10(43.3) | Pak 113/0(20.5) (Pakistan won by 10 wickets)
Zim 308/6(50.0) | Ken 147/10(36.0) (Zimbabwe won by 161 runs)

sample httpwebresponse

" src="/images/icons/onebox/cricket-40.gif" border=0 style="margin-right:2px"></a><td valign=top width=100%><table border=0 cellpadding=0 cellspacing=0 style="margin:2px 0"><tr><td>NZ 114/3(28.2) - LRPL Taylor* 23(27), SB Styris 16(23) | SL yet to bat<a href="/url?q=http://scoren.willow.tv/Match/1940&amp;sa=X&amp;ei=LL2RTZWPM4-GvgOd58HxBw&amp;ved=0CC0Q5AEoADAA&amp;usg=AFQjCNGjJP-QopTZ-8bkiI4KTKtpUN7IwA">scorecard</a>&nbsp;<tr><td>Aus 260/6(50.0) | Ind 261/5(47.4) (India won by 5 wickets)<a href="/url?q=http://scoren.willow.tv/Match/1933&amp;sa=X&amp;ei=LL2RTZWPM4-GvgOd58HxBw&amp;ved=0CC8Q5AEoADAA&amp;usg=AFQjCNHTIIMwJZb8MCx4bDblDud2mQhKcw">scorecard</a>&nbsp;<tr><td>WI 112/10(43.3) | Pak 113/0(20.5) (Pakistan won by 10 wickets)<a href="/url?q=http://scoren.willow.tv/Match/1937&amp;sa=X&amp;ei=LL2RTZWPM4-GvgOd58HxBw&amp;ved=0CDEQ5AEoADAA&amp;usg=AFQjCNGpzrqGMn8xQNQLx6V5JYcC8_4w7A">scorecard</a>&nbsp;<tr><td>Zim 308/6(50.0) | Ken 147/10(36.0) (Zimbabwe won by 161 runs)<a href="/url?q=http://scoren.willow.tv/Match/1935&amp;sa=X&amp;ei=LL2RTZWPM4-GvgOd58HxBw&amp;ved=0CDMQ5AEoADAA&amp;usg=AFQjCNEuTnrd1DqHxZfCLssDxzctulbbEw">scorecard</a>&nbsp;<tr><td><span class=a></span><tr><td><a

My code.I reached till here. However in the list box I am getting some weirrd values :(

Imports System.Text.RegularExpressions
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://www.google.co.in/search?hl=en&q=cricket+live+score&btnG=Search&aq=f&aqi=&aql=&oq=")
Dim response As System.Net.HttpWebResponse = request.GetResponse
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

Dim rssourcecode As String = sr.ReadToEnd
'Please help me in the below line
Dim r As New System.Text.RegularExpressions.Regex("<td>([^<]*)<a")
Dim matches As MatchCollection = r.Matches(rssourcecode)

For Each itemcode As Match In matches
'Please help me in the below line
CheckedListBox1.Items.Add(itemcode.Value.ElementAt(1))
Next
End Sub
End Class

See if this helps.

For Each itemcode As Match In matches
            With itemcode
                If .Value.Contains(")") Then '// make sure the .Value has data needed.
                    '// .Substring(4, .Value.Length - 6) = 4 for "<td>", -6 for "<td>" and the end of item for "<a".
                    CheckedListBox1.Items.Add(.Value.Substring(4, .Value.Length - 6))
                End If
            End With
        Next

Perfect, That helps

Now, what is the best way to pop up the contents of this CheckedListbox in our computer, without interupting the current process, we are doing.

I would probably use a Timer that runs that code on a different Thread every so often.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.