Skip to content

Instantly share code, notes, and snippets.

@csaez
Last active December 16, 2015 03:59
Show Gist options
  • Save csaez/5374046 to your computer and use it in GitHub Desktop.
Save csaez/5374046 to your computer and use it in GitHub Desktop.
Snippet to query wishdev's wishes. getWishes() function returns a dictionary with the wishes submited via http://goo.gl/Ikpxw (stored in google drive).
import urllib
from xml.dom import minidom
def getWishes():
URL = "http://goo.gl/67wYX"
urllib.urlcleanup()
xmldata = minidom.parseString(urllib.urlopen(URL).read())
columns = dict()
for node in xmldata.getElementsByTagName("entry"):
cell = node.getElementsByTagName("title")[0].childNodes[0].data
if len(cell) == 2 and "1" in cell:
content = node.getElementsByTagName("content")[0].childNodes[0].data
columns[cell[0]] = content
wishes = dict()
for v in columns.values():
wishes[v] = list()
for i, node in enumerate(xmldata.getElementsByTagName("entry")):
if i < len(columns):
continue
cell = node.getElementsByTagName("title")[0].childNodes[0].data
k = columns.get(cell[0])
content = node.getElementsByTagName("content")[0].childNodes[0].data
wishes[k].append(content)
return wishes
for wish in getWishes().get("I wish..."):
print "I wish: {}".format(wish)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment