input: Write a function to scrape and collect all the links from a given URL. The function should return a list of all the links found on the webpage. If the URL is invalid or the page cannot be accessed, the function should return an empty list.
  assert collect_links("http://www.example.com")==['http://www.iana.org/domains/example']
  assert collect_links("https://www.google.com")==['/intl/en_us/ads/', '/services/', '/intl/en_us/about.html', '/intl/en_us/policies/privacy/', '/intl/en_us/policies/terms/', '/intl/en_us/policies/privacy/ads/']
  assert collect_links("https://invalidurl.com")==[]
  assert collect_links("http://non-existing-website.com")==[]
  assert collect_links("")==[]
output: import requests
  from bs4 import BeautifulSoup
  
  def collect_links(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
          soup = BeautifulSoup(response.text, 'html.parser')
          links = [a['href'] for a in soup.find_all('a', href=True)]
          return links
      except:
          return []