input: Write a function to parse the given URL and return the protocol, domain name, and path as a dictionary in Python. If the URL is invalid, return an empty dictionary.
  assert url_parser('https://www.example.com/path/to/file')=={'Protocol': 'https', 'Domain name': 'www.example.com', 'Path': '/path/to/file'}
  assert url_parser('http://invalid-url')=={}
  assert url_parser('https://www.example.net/')=={'Protocol': 'https', 'Domain name': 'www.example.net', 'Path': '/'}
  assert url_parser('https://www.example.org/path/to/directory/')=={'Protocol': 'https', 'Domain name': 'www.example.org', 'Path': '/path/to/directory/'}
  assert url_parser('')=={}
output: def url_parser(url):
      if not url:
          return {}
      parts = url.split('://')
      if len(parts) != 2:
          return {}
      protocol = parts[0]
      rest = parts[1]
      domain_and_path = rest.split('/', 1)
      domain_name = domain_and_path[0]
      path = '/' + domain_and_path[1] if len(domain_and_path) > 1 else '/'
      return {'Protocol': protocol, 'Domain name': domain_name, 'Path': path}