parameters: ( url, output_folder, image_type='RED' )
return_statement: return image_list
docstring: Fetch all the files for a HiRISE image and return the list of files.
docstring_summary: Fetch all the files for a HiRISE image and return the list of files.
docstring_tokens: Fetch all the files for a HiRISE image and return the list of files .
function: def fetch_files( url, output_folder, image_type='RED' ):
      '''Fetch all the files for a HiRISE image and return the list of files.'''
  
      os.system('mkdir -p ' + output_folder)
  
      # The URL should look like this:
      # https://hirise-pds.lpl.arizona.edu/PDS/EDR/ESP/ORB_052800_052899/ESP_052893_1835/
  
      try:
          # python2 
          from BeautifulSoup import BeautifulSoup
          parsedDataPage = BeautifulSoup(urlopen(url).read())
      except:
          # python3
          try:
              from bs4 import BeautifulSoup        
              parsedDataPage = BeautifulSoup(urlopen(url).read(), "html.parser")
          except Exception as e:
              raise Exception("Error: " + str(e) + "\n" + 
                              "If this is a missing module error, please install " + \
                              "BeautifulSoup for python 2 or bs4 for python 3.\n" +
                              "Or do not use the --download-folder option.")
          
      # Loop through all the links on the page
      image_list = []
      for link in parsedDataPage.findAll('a'):
          filename = link.string
          if image_type not in filename:
              continue # Skip types that don't match
          
          full_url   = os.path.join(url,           filename)
          local_path = os.path.join(output_folder, filename)
          image_list.append(local_path)
  
          # Download the file if it is not already there        
          if not os.path.exists(local_path):
              cmd = 'wget ' + full_url + ' -O ' + local_path
              print (cmd)
              os.system(cmd)
      
      return image_list
function_tokens: def fetch_files ( url , output_folder , image_type = 'RED' ) : os . system ( 'mkdir -p ' + output_folder ) # The URL should look like this: # https://hirise-pds.lpl.arizona.edu/PDS/EDR/ESP/ORB_052800_052899/ESP_052893_1835/ try : # python2  from BeautifulSoup import BeautifulSoup parsedDataPage = BeautifulSoup ( urlopen ( url ) . read ( ) ) except : # python3 try : from bs4 import BeautifulSoup parsedDataPage = BeautifulSoup ( urlopen ( url ) . read ( ) , "html.parser" ) except Exception as e : raise Exception ( "Error: " + str ( e ) + "\n" + "If this is a missing module error, please install " + "BeautifulSoup for python 2 or bs4 for python 3.\n" + "Or do not use the --download-folder option." ) # Loop through all the links on the page image_list = [ ] for link in parsedDataPage . findAll ( 'a' ) : filename = link . string if image_type not in filename : continue # Skip types that don't match full_url = os . path . join ( url , filename ) local_path = os . path . join ( output_folder , filename ) image_list . append ( local_path ) # Download the file if it is not already there         if not os . path . exists ( local_path ) : cmd = 'wget ' + full_url + ' -O ' + local_path print ( cmd ) os . system ( cmd ) return image_list