User:Marlon: Difference between revisions
Andre Castro (talk | contribs) |
Andre Castro (talk | contribs) |
||
Line 19: | Line 19: | ||
==prototype for random torrent== | ==prototype for random torrent== | ||
can be dumped into a hmtm file as a test | |||
touch test.html | |||
python random_torrent.py > test.html | |||
<source lang=python> | <source lang=python> | ||
#!/usr/bin/python | #!/usr/bin/python |
Revision as of 17:20, 18 March 2013
(^○^)オ(^▽^)ハ(^0^)ツ〜!!
while (marlon = happy) {
menno = happy
}
2012/2013
First Trimester
prototype for random torrent
can be dumped into a hmtm file as a test
touch test.html python random_torrent.py > test.html
#!/usr/bin/python
# encoding: utf-8
# NEEDS to be chmod+x read_torrent.py
import cgi #for the cgi
import cgitb; cgitb.enable()
import lxml.etree, os
from random import choice
#choose a fild from the xml folder
path = "/home/andre/Documents/PZI/torrent/xml/"
dir_files = os.listdir(path)
f = "xml/" + choice(dir_files)
#print 'file', f
#print
doc = lxml.etree.parse(f)# parse the data
#print 'lxml obj', doc #print the lxml object
#print lxml.etree.tostring(doc)# print the whole content
nodes = doc.xpath("//torrent")
t_choice = choice(nodes)
t_info = []
for children in t_choice:
p = children.text
t_info.append(p)
#print t_info
#id t_info[0]
#title
#magnet
print "Content-type: text/html"
print
print "<html><head><title>RANDOM TORRENT</title></head><body><h3>ID: %s</h3><h3>TITLE: %s</h3><h3>MAGNET: %s</h3></body></html>" % (t_info[0], t_info[1], t_info[2])
Second Trimester
Thematic: Media–object
Reading, Writing & Research Methodologies
Trim I Project descriptions / Annotations / Poster
Trim II Cultural Hegemony