MCPcopy Create free account
hub / github.com/ActiveState/code / process

Function process

recipes/Python/276961_ljopmlpy/recipe-276961.py:37–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35</html>"""
36
37def process():
38 url = "http://www.livejournal.com/users/" + user + "/data/foaf"
39 try:
40 fp = urllib.urlopen(url)
41 except IOError:
42 print "Content-type:text/html\n\n"
43 print "<h1>Error accessing FOAF URL!</h1>"
44 url_data = fp.read()
45 fp.close()
46 print "Content-type:text/xml\n\n"
47 print """<?xml version="1.0" encoding="utf-8"?>
48<opml version="1.0">
49<head>
50 <title>LiveJournal Subsriptions</title>
51 <dateCreated>GMT</dateCreated>
52</head>
53<body>
54 <outline title="Subscriptions">"""
55
56 content = re.split("<foaf:Person>",url_data)
57 count = 0
58 for x in content :
59 m = re.match("[ \t\n]*<foaf:nick>([ \t\w\n]*)",x)
60 if m != None :
61 if count != 1 :
62 rep = m.group(1)
63 print "<outline title=\"" + rep + "\" htmlUrl=\"http://www.livejournal.com/users/" + rep + "/\" type=\"rss\" xmlUrl=\"http://www.livejournal.com/users/" + rep + "/data/rss\" />\n";
64 count = count + 1
65 print "</outline></body></opml>"
66
67if form :
68 process()

Callers 3

recipe-276961.pyFile · 0.70
recipe-66061.pyFile · 0.50
recipe-173976.pyFile · 0.50

Calls 5

readMethod · 0.45
closeMethod · 0.45
splitMethod · 0.45
matchMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected