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