JSON.stringify JQuery Example

Written on:September 10, 2013
Add One

Since JSON is a browser specific object it may not be available with older version of browsers like IE8 and others. Calling JSON.stringify in such cases may result error if not taken care of boowser version.

You can use a jQuery plugin named [ jquery-json ] to achieve similar functionality. This can be downloaded from Google Code repository


Example of JSON.stringify JQuery using jQuery

var thing = {Widget:'Bar Chart', NumCols:6};

var encoded = $.toJSON( thing );
// output "{"Widget":"Bar Chart","NumCols":6}"

Could not find stored procedure dbo.aspnet_CheckSchemaVersion

Written on:August 6, 2013
Add One

While trying to run a demo Asp.Net MVCapplications I suddenly got this error

“Could not find stored procedure dbo.aspnet_CheckSchemaVersion”

After some googling I came to know that this is because I created the schema from Model and ASP.Net membership related objects are not available in the newly created database. To add this procedure you need to run Developer command prompt for Visual Studio.  


On the command prompt type aspnet_regsql . This will invoke “Asp.Net SQL Server Setup Wizard” something like below :


Just follow the steps and select the desired database you are getting issue with and rest will be fixed by  the wizard.

Command to Start Stop IIS7 From Command Prompt

Written on:July 29, 2013
Add One

Probably you may not like each time starting and stopping IIS or other servers by using the UI. Best way to such things quickly is always the command line. I have installed IIS Express and found that there is a slight difference in the command from earlier versions of IIS.

Command to start IIS 7

net start W3SVC

Command to stop IIS 7

net stop W3SVC

Scraping JavaScript Generated Pages – How to ?

Written on:July 11, 2013
Add One

Traditional way of scraping no longer works in many cases as JavaScript generated user interfaces are getting popular day by day. By traditional,  I mean to say you were just downloading the html content and extracting all data you need. Now a days with technology advancements more more more libraries are coming which is reducing the server side load and lets you render the webpage at client side. Such pages are problematic and require a different way to handle.

My preferred approach to handle such cases is using some headless browser like ( Phantom JS ). It lets you write and  execute your JavaScript code which in turn can be used to collect scrapped data and write it to some file.

To make things more easy and convenient Nick Rabinowitz has written a small library named pjscrape which is based on Phantom JS. This library takes few inputs like content selector and url selector and rest does most of the work of identifying URL’s and navigating to next pages for you.  In the below example you can see how a shopping site is being scrapped and data is being collected using various jQuery selectors.

As you can see code is pretty self explanatory. In the very first section you are setting various parameters like timeouts, depth of pages to go etc. In second section we need to provide start url and next page selectors. And in the next section you can put your selector code which is being stored as an Object array. Finally all data gets saved in CSV format because of the “format: ‘csv’” setting in config section.

In one of my previous article I had mentioned about scraping using selenium but that is a less preferred approach as it takes too much time.