input: Write a function to read the contents from a given URL and return the content as a string if the request is successful, otherwise return None. If the URL is invalid or the request fails, the function should handle the error and return None.
  
  assert read_url("https://www.example.com") == "Example Domain"
  assert read_url("https://nonexistentwebsite.com") == None
  assert read_url("https://www.google.com") == "Please enable JavaScript to use Google Search."
  assert read_url("") == None
  assert read_url("invalidurl") == None
output: import requests
  
  def read_url(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
          return response.text
      except (requests.RequestException, ValueError):
          return None