Thursday, February 25, 2010

Accessing live cricket score from C# Win Forms Application - Using Screen Scrapping technique.

Quite often during the crucial stages of a cricket match, we might want to refresh the browser frequently, in order to get the latest score. And more importantly we need to stay in the browser window.

This can be done programmatically, through the following steps.

1. Launch an embedded web browser in a C# win forms application.

2. Supply the URL of the page which publishes the latest cricket score.

3. Capture the entire HTMLDOM of that page.

4. Identify the HTML element which displays the score (that is changing) and save the index of that HTML element (the index is unique for all the HTML elements).

5. Load the entire HTMLDOM once again and Get the element by index (already saved).

6. Querying for the text at that element gives you the latest score.

7. Run the steps 5, 6 on a timer (say 7 seconds to keep refreshing the page.)

Note: The HTML markup of the page should not change while scrapping.

Code Snippets:

Steps -1, 2

image

Steps -3, 4

 image

Steps 5,6,7

image

This technique can be ideally used to ‘scrape’ weather updates, Stock rates etc, which keeps changing frequently.

Wednesday, January 20, 2010

Accessing Twitter API through C# code

I wanted to share the C# code which i used to access , the Twitter API programmatically .

The Workflow.

1. Twitter exposes almost all its data underneath, through its RESTFul Services

2. The Client using this code  can be a Webclient(asp.net , asp.net mvc etc ) or a Desktop client (Winforms , Console Application etc.)

3. The data being returned from those services are in XML or JSON format.

Code Snippet

image

Saturday, November 14, 2009

OOPS , Design Patterns – Concepts and Handson

Jai's blog - explains the importance of code metrics,clean code , tips for refactoring etc.

ootips – OOPS concepts and UML diagrams to simulate the same.

design patterns– Design patterns explained , with examples.

Wednesday, April 1, 2009