input: Write a function to parse the given URL and return a dictionary containing the protocol, domain name, and path using Python. If the URL is invalid, return an empty dictionary.
  assert parse_url('https://www.example.com/path/to/file')=={'protocol': 'https', 'domain_name': 'www.example.com', 'path': '/path/to/file'}
  assert parse_url('http://example.org/test')=={'protocol': 'http', 'domain_name': 'example.org', 'path': '/test'}
  assert parse_url('invalid_url')=={}
  assert parse_url('ftp://user:password@ftp.example.com/upload')=={'protocol': 'ftp', 'domain_name': 'ftp.example.com', 'path': '/upload'}
  assert parse_url('')=={}
output: def parse_url(url):
      if not url:
          return {}
      parts = url.split('://', 1)
      if len(parts) != 2:
          return {}
      protocol, rest = parts
      if '/' not in rest:
          domain_name = rest
          path = ''
      else:
          domain_name, path = rest.split('/', 1)
          path = '/' + path
      return {'protocol': protocol, 'domain_name': domain_name, 'path': path}