Skip to content

Instantly share code, notes, and snippets.

@lfranchi
Created February 10, 2012 21:26
Show Gist options
  • Save lfranchi/1793007 to your computer and use it in GitHub Desktop.
Save lfranchi/1793007 to your computer and use it in GitHub Desktop.
import xml.etree.ElementTree, numpy
f = open("2.html", 'r')
#f = open("1.html", 'r')
html = f.readlines()
root = xml.etree.ElementTree.fromstringlist(html)
print list(root)
nums = []
cur = 0
item = root
def countItem(item, depth):
nums.append(depth)
numChildren = len(list(item))
if numChildren == 0:
return
for i in range(numChildren):
countItem(list(item)[i], depth+1)
countItem(root, 0)
print "list: %s" % nums
print "stddev: %s" % numpy.std(nums)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment