Anonymous     Python     02 Sep 2011    
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- 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)