I want to classify a given set of web pages to different classes, mainly to 3 classes(product page, index page and product-related items page). I think it can be done using analyzing their structure. I just look for comparing the web pages based on their DOM(Document Object Model) structure. I want to whether there is library in python for resolving this problem. 
Thanks in advance.
First you would need to identify which elements in the page actually uniquely identify a page as being of a specific webpage-class.
Then you could use a library like BeautifulSoup to actually look through the document to see if those elements exist.
Then you would just need a series of if/elifs to determine if a page has the qualifying elements, if so classify it as the appropriate webpage-class.
Web page structure comparison using python