Divisive former academic came second to the Green Party’s Hannah Spencer in the Gorton and Denton by-election