<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_substances(identifier, namespace='sid', as_dataframe=False, **kwargs):
 """Retrieve the specified substance records from PubChem. :param identifier: The substance identifier to use as a search query. :param namespace: (optional) The identifier type, one of sid, name or sourceid/<source name>. :param as_dataframe: (optional) Automatically extract the :class:`~pubchempy.Substance` properties into a pandas :class:`~pandas.DataFrame` and return that. """

    results = get_json(identifier, namespace, 'substance', **kwargs)
    substances = [Substance(r) for r in results['PC_Substances']] if results else []
    if as_dataframe:
        return substances_to_frame(substances)
    return substances