Skip to content

Instantly share code, notes, and snippets.

@FiloSottile
FiloSottile / gist:2352407
Created April 10, 2012 16:02
Get element by id from HTML document using only HTMLParser
import HTMLParser
class IDParser(HTMLParser.HTMLParser):
"""Modified HTMLParser that isolates a tag with the specified id"""
def __init__(self, id):
self.id = id
self.result = None
self.started = False
self.depth = {}
self.html = None
@FiloSottile
FiloSottile / gist:2667279
Created May 12, 2012 15:54
Render only an element with PhantomJS
page.clipRect = page.evaluate(function() {
return document.getElementById(ELEMENT_ID).getBoundingClientRect();
});