Searches the shop wizard for the given item, returns result
        
        Uses the given parameters to send a search request with the Shop Wizard.
        Automatically parses the search results into individual items and appends
        them to and returns a ShopWizardResult. 
           
        Parameters:
           usr (User) -- User to search with
           item (str, Item) -- Item to search for
           area (str) -- Area to search in (ShopWizard.SHOP, ShopWizard.GALLERY)
           scope (str) -- Scope to search for (ShopWizard.CONTAINING, ShopWizard.EXACT)
           min (str) -- Minimum price
           max (str) -- Maximum price
           
        Returns
           ShopWizardResult - Search results
           
        Raises
           activeQuest
           shopWizBanned
           parseException
           invalidSearch

def search(usr, item, area = "shop", scope = "exact", min = "0", max = "99999"):
        """ Searches the shop wizard for the given item, returns result
        
        Uses the given parameters to send a search request with the Shop Wizard.
        Automatically parses the search results into individual items and appends
        them to and returns a ShopWizardResult. 
           
        Parameters:
           usr (User) -- User to search with
           item (str, Item) -- Item to search for
           area (str) -- Area to search in (ShopWizard.SHOP, ShopWizard.GALLERY)
           scope (str) -- Scope to search for (ShopWizard.CONTAINING, ShopWizard.EXACT)
           min (str) -- Minimum price
           max (str) -- Maximum price
           
        Returns
           ShopWizardResult - Search results
           
        Raises
           activeQuest
           shopWizBanned
           parseException
           invalidSearch
        """
        if not usr:
            raise invalidUser
        
        if not item:
            raise invalidSearch
            
        if area != ShopWizard.SHOP and area != ShopWizard.GALLERY:
            logging.getLogger("neolib.shop").info("Invalid area supplied for shop wizard search: " + area)
            raise invalidSearch
            
        if scope != ShopWizard.CONTAINING and scope != ShopWizard.EXACT:
            logging.getLogger("neolib.shop").info("Invalid scope supplied for shop wizard search: " + area)
            raise invalidSearch
            
        if int(min) < 0:
            logging.getLogger("neolib.shop").info("Invalid min value supplied for shop wizard search: " + min)
            raise invalidSearch
            
        if int(max) > 99999:
            logging.getLogger("neolib.shop").info("Invalid max value supplied for shop wizard search: " + max)
            raise invalidSearch
            
        if isinstance(item, Item):
            item = item.name
        
        pg = usr.getPage("http://www.neopets.com/market.phtml?type=wizard")
        
        form = pg.form(action="market.phtml")
        form.update({'shopwizard': item, 'table': area, 'criteria': scope, 'min_price': str(min), 'max_price': str(max)})
        pg = form.submit()
        
        # Indicates shop wizard banned
        if "too many searches" in pg.content:
            time = pg.find("b", text = "Whoa there, too many searches!").parent.p.b.item
            e = shopWizBanned()
            e.time = time
            raise e
            
        # Indicates a faerie quest
        if "You're working for a faerie" in pg.content:
            logging.getLogger("neolib.shop").info("Could not search for " + item + ". A Faerie quest is active")
            raise activeQuest
            
        if "did not find" in pg.content:
            if item in pg.content:
                return False # Indicates UB item
            elif "...</span>" in pg.content:
                # Probably invalid item
                raise invalidSearch
            
        return ShopWizardResult(pg, usr)