input: Write a function to scrape the table at the given URL and extract the planets information (name, mass, and distance from the sun). If the table or any of the required columns are missing, 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': '0.055 Earth masses', 'distance_from_sun': '0.39 AU'},{'name': 'Venus', 'mass': '0.815 Earth masses', 'distance_from_sun': '0.723 AU'},...]
  assert scrape_planets_info('https://example.com')==[]
  assert scrape_planets_info('https://invalidurl.com')==[]
output: def scrape_planets_info(url):
      import requests
      from bs4 import BeautifulSoup
      try:
          response = requests.get(url)
          response.raise_for_status()
          soup = BeautifulSoup(response.content, 'html.parser')
          table = soup.find('table', {'class': 'wikitable'})
          if not table:
              return []
          headers = [header.text.strip() for header in table.find_all('th')]
          if 'Name' not in headers or 'Mass' not in headers or 'Distance from Sun' not in headers:
              return []
          name_idx = headers.index('Name')
          mass_idx = headers.index('Mass')
          dist_idx = headers.index('Distance from Sun')
          rows = table.find_all('tr')[1:]
          planets = []
          for row in rows:
              cols = row.find_all('td')
              if len(cols) > max(name_idx, mass_idx, dist_idx):
                  name = cols[name_idx].text.strip()
                  mass = cols[mass_idx].text.strip()
                  distance = cols[dist_idx].text.strip()
                  planets.append({'name': name, 'mass': mass, 'distance_from_sun': distance})
          return planets
      except:
          return []