lxml fromstring() yields HTML code with &#13; everywhere
<p>I'm reading in a webpage from the intranet via</p>

<pre><code>        webpage = urllib2.urlopen(urllib2.Request(self.URL))
        doc =  webpage.read()
        root = html.fromstring(doc)
</code></pre>

<p>I noticed that I can't read anything via findall() from this root Object, I then looked into the root Object via:</p>

<pre><code>code = etree.tostring(root)
</code></pre>

<p>which yielded me the exact HTML code but with </p>

<blockquote>
  <p><code>&amp;#13;</code></p>
</blockquote>

<p>everywhere in the Code. I think this might cause my parsing issues (I hope so at least).</p>

<p>How can I get clean HTML code out of this? Any encoding/decoding needed?</p>

<p>I've tried to decode it to UTF-8, but that didn't work appearantly.</p>

<pre><code>print code.decode('utf-8')
</code></pre>

<p>Nevermind, that wasn't the issue.</p>

<p>The problem was that I downloaded the site and parsed it offline, where it sneaked in </p>

<p>&lt; tbody ></p>

<p>tags that I used in my Xpath queries. This caused my script not to work when downloading the website fresh via lxml.</p>

python lxml elementtree