Skip to content

Instantly share code, notes, and snippets.

@scturtle
Created February 27, 2013 06:51
Show Gist options
  • Save scturtle/5045784 to your computer and use it in GitHub Desktop.
Save scturtle/5045784 to your computer and use it in GitHub Desktop.
timeline of any user in renren.com
# coding: utf-8
from __future__ import unicode_literals
import re
import sys
import requests
import HTMLParser
cookie_t = ''
uid = ''
filename = ''
pages = 1
baseurl = 'http://status.renren.com/GetSomeomeDoingList.do?userId=%s&curpage=%d'
# html preprocessing
p1 = re.compile(r'<a[^>]+>')
p2 = re.compile(r'</a>')
p3 = re.compile(r"<img.*alt='(.*)'.*/>")
hp = HTMLParser.HTMLParser()
p = lambda s: hp.unescape(p3.sub(r'[\1]', p1.sub('[', p2.sub(']', s)))).encode('utf-8')
# output
sys.stdout = open(filename, 'w')
for i in xrange(pages):
# fetching
sts = requests.get(baseurl % (uid, i), cookies={'t': cookie_t}).json()
for st in sts['doingArray']:
print st['dtime']
print p(st['content'])
if 'rootContent' in st:
print p(st['rootContent'])
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment