input: Write a function to scrape the table at the given URL and extract the planets' information including their name, mass, and distance from the sun. Return a list of dictionaries where each dictionary contains the name, mass, and distance from the sun of a planet. If the URL is invalid or the table does not exist, return an empty list.
  assert scrape_planets_info("https://en.wikipedia.org/wiki/List_of_gravitationally_rounded_objects_of_the_Solar_System")==[{'name': 'Mercury', 'mass': '3.30×10²³', 'distance_from_sun': '57.9'}]
  assert scrape_planets_info("https://example.invalid/typo")==[]
output: import requests
  from bs4 import BeautifulSoup
  
  def scrape_planets_info(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
          soup = BeautifulSoup(response.text, 'html.parser')
          table = soup.find('table', {'class': 'wikitable'})
          if not table:
              return []
          rows = table.find_all('tr')
          planets_info = []
          headers = [header.text.strip() for header in rows[0].find_all('th')]
          for row in rows[1:]:
              cells = row.find_all('td')
              if len(cells) >= 3:
                  planet_info = {
                      'name': cells[0].text.strip(),
                      'mass': cells[1].text.strip(),
                      'distance_from_sun': cells[2].text.strip()
                  }
                  planets_info.append(planet_info)
          return planets_info
      except (requests.RequestException, AttributeError):
          return []