input: Write a function to scrape an online news website to get the headlines. The function should take the URL of the website as input and return a list of headlines.
  assert scrape_headlines("https://www.news.com/")==["Headline 1", "Headline 2", "Headline 3"]
  assert scrape_headlines("https://www.anothernews.com/")==["News 1", "News 2"]
  assert scrape_headlines("https://www.invalidurl.com/")==[]
output: def scrape_headlines(url):
      try:
          import requests
          from bs4 import BeautifulSoup
          response = requests.get(url)
          if response.status_code != 200:
              return []
          soup = BeautifulSoup(response.content, 'html.parser')
          headlines = [h.text.strip() for h in soup.find_all('h1')]
          return headlines
      except:
          return []