input: Write a function to create a Python web scraper that collects all the links from a given website URL. The function should return a list of all the collected links. If the URL is invalid or no links are found, the function should return an empty list.
  
  def collect_links(url):
      import requests as req
      from bs4 import BeautifulSoup
      
      try:
          r = req.get(url)
          soup = BeautifulSoup(r.text, "html.parser")
          links = [link.get('href') for link in soup.find_all('a')]
          return links
      except Exception as e:
          return []
  
  assert collect_links("http://www.example.com/")==['http://www.iana.org/domains/example']
  assert collect_links("http://www.nonexistentwebsite.com/")==[]
  assert collect_links("http://www.google.com/")==['/intl/en/about.html', '/store/apps']
  assert collect_links("")==[]
  assert collect_links("http://www.example.com/notfound")==[]
output: def collect_links(url):
      import requests as req
      from bs4 import BeautifulSoup
      
      try:
          r = req.get(url)
          soup = BeautifulSoup(r.text, "html.parser")
          links = [link.get('href') for link in soup.find_all('a')]
          return links
      except Exception as e:
          return []