def from_url(reddit_session, url, comment_limit=0, comment_sort=None,
                 comments_only=False, params=None):
        """Request the url and return a Submission object.

        :param reddit_session: The session to make the request with.
        :param url: The url to build the Submission object from.
        :param comment_limit: The desired number of comments to fetch. If <= 0
            fetch the default number for the session's user. If None, fetch the
            maximum possible.
        :param comment_sort: The sort order for retrieved comments. When None
            use the default for the session's user.
        :param comments_only: Return only the list of comments.
        :param params: dictionary containing extra GET data to put in the url.

        """
        if params is None:
            params = {}

        parsed = urlparse(url)
        query_pairs = parse_qs(parsed.query)
        get_params = dict((k, ",".join(v)) for k, v in query_pairs.items())
        params.update(get_params)
        url = urlunparse(parsed[:3] + ("", "", ""))
        if comment_limit is None:  # Fetch MAX
            params['limit'] = 2048  # Just use a big number
        elif comment_limit > 0:  # Use value
            params['limit'] = comment_limit
        if comment_sort:
            params['sort'] = comment_sort

        response = reddit_session.request_json(url, params=params)
        if comments_only:
            return response[1]['data']['children']
        submission = Submission.from_json(response)
        submission._comment_sort = comment_sort  # pylint: disable=W0212
        submission._params = params  # pylint: disable=W0212
        return submission
def from_url ( reddit_session , url , comment_limit = 0 , comment_sort = None , comments_only = False , params = None ) : if params is None : params = { } parsed = urlparse ( url ) query_pairs = parse_qs ( parsed . query ) get_params = dict ( ( k , "," . join ( v ) ) for k , v in query_pairs . items ( ) ) params . update ( get_params ) url = urlunparse ( parsed [ : 3 ] + ( "" , "" , "" ) ) if comment_limit is None : params [ 'limit' ] = 2048 elif comment_limit > 0 : params [ 'limit' ] = comment_limit if comment_sort : params [ 'sort' ] = comment_sort response = reddit_session . request_json ( url , params = params ) if comments_only : return response [ 1 ] [ 'data' ] [ 'children' ] submission = Submission . from_json ( response ) submission . _comment_sort = comment_sort submission . _params = params return submission
Request the url and return a Submission object.

        :param reddit_session: The session to make the request with.
        :param url: The url to build the Submission object from.
        :param comment_limit: The desired number of comments to fetch. If <= 0
            fetch the default number for the session's user. If None, fetch the
            maximum possible.
        :param comment_sort: The sort order for retrieved comments. When None
            use the default for the session's user.
        :param comments_only: Return only the list of comments.
        :param params: dictionary containing extra GET data to put in the url.