Visible and near-infrared divertor spectroscopy on the MAST and JET-ILW tokamaks