For US stocks, you could get it from
http://biz.yahoo.com/ic/ind_index.html
and sreeen scrape by walking the tree of html links.
Yahoo UK also have sector and industry data, but I think the page formats are not the same as the US ones.
I also seem to recall that Dow Jones web site somewhere has all the DJ sector/industry indices with details of their calculation and I think Excel spreadsheets containing the constituents for each index. Might have been for European indices - I can't remember.