User:Eleanorg/RSS Manipulation
From NetworkedMedia
What turns the Pirate Bay on?
This makes a pretty (?) SVG from users' requests for porn films that they are looking for, or have been unable to find, on TPB.
import lxml.etree, urllib2, codecs, random # Read from live URL page = urllib2.urlopen("https://forum.suprbay.org/syndication.php?fid=50") # Make document into an etree object doc = lxml.etree.parse(page) print """<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="2000" height="650" id="svg2" version="1.1" inkscape:version="0.47 r22583" sodipodi:docname="text1.svg"> <defs id="defs4"> <inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" id="perspective10" /> </defs> <sodipodi:namedview id="base" pagecolor="#f2f071" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="1" inkscape:pageshadow="2" inkscape:zoom="0.35" inkscape:cx="375" inkscape:cy="508.57143" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" inkscape:window-width="745" inkscape:window-height="889" inkscape:window-x="5" inkscape:window-y="47" inkscape:window-maximized="0" /> <metadata id="metadata7"> <rdf:RDF> <cc:Work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> <dc:title></dc:title> </cc:Work> </rdf:RDF> </metadata> <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1">""" for item in doc.xpath("//item"): title = item.xpath(".//title/text()")[0] print """<text xml:space="preserve" style="font-size:""" + str(random.randint(1,150)) + """px;font-style:normal;font-weight:normal;fill:#fb""" + str(random.randint(7040,7099)) + """;fill-opacity:1;stroke:none;font-family:Sans" x="142.85715" y="189.50504" id="text2824"><tspan sodipodi:role="line" id="tspan2826" x=" """ + str(random.randint(-100,60)) + """" y=" """ + str(random.randint(250,550)) + """"> """ + title + """</tspan> </text>""" print """ </g> </svg>"""
