Suppose my HTML looks like this:
html = '<HTML><BODY><a id="id1">test</a><a id="id2">test2</a></BODY></HTML>'
I extract the 2nd link: node = doc.css("a#id2")[0]
How do I get the starting index of this node HTML in the HTML source? Which is 32?
html.slice(32, SOMETHING) = '<a id="id2">...'
Note: I know this is a trivial example but the solution should address cases where the node I extract isn't unique in the HTML.