Skip to main content Skip to main navigation Skip to search Skip to footer
Type to Search Subscribe View Tags

Live Data Updates through Websites

Live Data Updates through Websites
Anbuselvan Vetriselvan - Lead Engineer | November 13, 2014
78 Views

In today’s world, people spend a lot of time catching up on several fields - education, science, sports, politics, and travel. As all this information is scattered across various websites on the internet, we usually tend to gather information from these websites and then collate it.

Accessing a single website that has all the information or services can help significantly reduce time.  This approach brings multiple site content under a single umbrella and also reduces the user’s internet bandwidth. The user can easily access multiple websites using a single application URL in the web browser and need not enter the accessing website URL.

The WebClient wrapper class is one of the features available in .NET technologies. It defines the data extraction procedure, which is used to download resources with user specified URLs, and  the class provides common methods for sending or receiving data from any local intranet, or Internet resource identified by a URL.

“System.Net.Sockets” is a namespace which contains the WebClient object or wrapper class. It is used to extract data from HTML, XML and CSV file types.

The WebClient class provides four methods for downloading data from a resource:

  1. The OpenRead method returns data from the resource as a stream
  2. The DownloadString method returns data from the resource as a string
  3. The DownloadData method downloads data from a resource and then returns a byte array
  4. The DownloadFile method downloads data from a resource to a local file

Block Diagram

Block Diagram

How it works

The target resource website provides data in the HTML format. Every ten minutes, we automatically get the updated data from the target website using the WebClient object in .Net. WebClient provides asynchronous methods for fetching webpage data as well; they are named similar to the synchronous methods.

The OpenRead method is used to retrieve the following information and then this is appended in the web application:

  1. Train status
  2. Electricity board

Possibility: We will be able to integrate the content from multiple sites in our application.

I have implemented a sample application using this logic and attached a screen shot below:

Implementing a Sample Application using this logic

Disadvantage:

It takes more time to fetch the content from the target website if the internet connection is slow.

Supports the following platforms:

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported) & Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported).

.NET Framework

  • Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1 & 1.0
  • .NET Framework Client Profile

References:


Contact Us
MAX CHARACTERS: 10,000

We will treat any information you submit with us as confidential. Please read our privacy statement for additional information.

We will treat any information you submit with us as confidential. Please read our privacy statement for additional information.

Sign in to Add this article to your Reading List
Register