Use try..except for urlencode import