Hi!
The function you're searching for is the API
GetItemStats, which returns the stats of an item, given the itemlink or even the name. From the example on the bottom of the page you can learn how to use the function. After using it you only have to check the entrys of the table for the given stats (e.g. "intellect").
While primary stats - such as intellect, stamina, etc. - are unlikely to change their role in future, this may not apply on secondary stats - such as multistrike, critical strike, etc. -, which may become more or less important for each specialization. So, if you're planning on including an auto-loot-system for secondary stats you have to update your addon everytime something's changed.
Cheers,
Odjur