Factor out href extraction and string conversion.