On Mon, Apr 13, 2009 at 2:00 AM, Khyron <[email protected]> wrote:

>
> Ok.
>
> So then, in Python, which library do I need to inmport to parse the
> returned
> XML?  I have simplejson (needed it for python-twitter) so maybe that
> would
> be easier?


Yes.  If you decode the content you get from a status request, like this:

data = simplejson.loads(content)

The number of statuses you have retrieved will be the length of the
resulting object -- len(data)

However, you'll need to page through the results (make additional http
requests) to get more than 200 statuses.  You can concatenate the received
content before parsing it. That would look like the following, in a loop:

if response.status == 200:
                    if
response['content-type'].startswith('application/json'):
                        try:
                            data = json.loads(content)
                        except:
                            print "json decode failed: %s" % (content)
                            return False

                        if 'next_page' in data:
                            next_page = data['next_page']
                        if 'results' in data:
                            data = data['results']

                        if not all:
                            return data
                        elif len(data) and i < self.max_pages:
                            concat_content += (data)

Reply via email to