input: Write a function to build a web scraper in Python that collects all the links from a given website URL. If the URL is empty or invalid, the function should return an empty list. The function should use the `requests` and `BeautifulSoup` libraries to perform the scraping.
  
  assert collect_links("http://www.example.com/")==['/', '/about', '/contact']
  assert collect_links("")==[]
  assert collect_links("http://www.invalidurl.com/")==[]
output: def collect_links(url):
      if not url:
          return []
      try:
          import requests
          from bs4 import BeautifulSoup
          response = requests.get(url)
          if response.status_code != 200:
              return []
          soup = BeautifulSoup(response.text, 'html.parser')
          links = [a['href'] for a in soup.find_all('a', href=True)]
          return links
      except:
          return []