input: Write a function to collect all the links from a given website using a web scraper in Python. The function should return a list of links found on the webpage. If the request fails, it should return an empty list.
  
  
  import requests as req 
  from bs4 import BeautifulSoup 
  
  def collect_links(url: str) -> list:
      try:
          # GET request 
          r = req.get(url) 
          if r.status_code != 200:
              return []
          
          # parse the downloaded homepage and grab all text
          soup = BeautifulSoup(r.text, "html.parser") 
          
          # find and collect all links 
          links = [link.get('href') for link in soup.find_all('a')]
          return links
      except req.RequestException:
          return []
  
  assert collect_links("http://www.example.com/") != []
  assert collect_links("http://www.nonexistenturl12345.com/") == []
  assert collect_links("http://www.example.com/") != []
  assert collect_links("http://www.example.com/") != []
  
output: def collect_links(url: str) -> list:
      try:
          r = req.get(url)
          if r.status_code != 200:
              return []
          soup = BeautifulSoup(r.text, "html.parser")
          links = [link.get('href') for link in soup.find_all('a')]
          return links
      except req.RequestException:
          return []