input: Write a function to scrape an online news website to get the headlines. The function should take a URL as input and return a list of headlines. If the URL is invalid or there are no headlines, it should return an empty list.
  assert scrape_headlines("https://www.news.com/")==["Breaking News: Accidents Happen", "Global Warming Threat", "Tech Boom Continues", "Economic Downturn Affects Market"]
  assert scrape_headlines("https://random.com/")==[]
  assert scrape_headlines("")==[]
output: import requests
  from bs4 import BeautifulSoup
  
  def scrape_headlines(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
          soup = BeautifulSoup(response.text, 'html.parser')
          headlines = [h.text.strip() for h in soup.find_all('h1')]
          return headlines
      except:
          return []