# -*- coding: utf-8 -*-
import datetime
import urllib
import leaf
def getJjfeed(name):
f = urllib.urlopen("http://m.livejournal.com/read/user/"+name+"/").read()
document = leaf.parse(f)
return document
name = "ledovsky"
jj_obj = getJjfeed(name)
#count = jj_obj("html body div.l div.p-journal ul.post-list li.post-list-item div.item a")
posts = jj_obj("html body div.l div.p-journal ul.post-list li.post-list-item")
count = len(posts)
print "All %d post by user %s." %(count,name)
for i in posts:
titles = i.get("div.item h3.item-header a")
url = titles.element.get("href")
post = i.get("div.item div.item-text")
#text_len = len(post.text)
try:
count_comments = i("p.item-make-comments a")[1]
count_comments_full = count_comments.text
except:
count_comments_full = "0"
print "\nTitl: %s \nUrl: %s\nCount comments: %s\nPost: %s" %(titles.text,url,count_comments_full,post.text)