title: Extract URLs with lxml
body: <p>I've scraped some HTML into a large txt file (~50k lines), and would like to extract a specific set of URLs. The URL that I'm after is in one of two patterns:</p>
  
  <p>First</p>
  
  <pre><code>&lt;div class="pic"&gt;
    &lt;a href="https://www.site.com/joesmith"&gt;&lt;img alt="Joe Smith" class="person_image" src="https://s3.amazonaws.com/photos.site.com/medium_jpg?12345678"&gt;&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Second</p>
  
  <pre><code>&lt;div class="name"&gt;
    &lt;a href="https://www.site.com/joesmith"&gt;Joe Smith&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The text that I need is <code>https://www.site.com/joesmith</code>. I'm working with the lxml for the first time, and I'm having a hard time getting this together.</p>
  
  <p>Here's my code</p>
  
  <pre><code>from lxml import etree
  from io import StringIO
  
  def read(filename):
    file = open(filename, 'r')
    text = file.read()
    file.close()
    out = unicode(text, errors='ignore')
    return out
  
  def parse(filename):
    data = read(filename)
    parser = etree.HTMLParser()
    tree = etree.parse(StringIO(data), parser)
    result = etree.tostring(tree.getroot(), pretty_print=True, method='HTML')
    urls = result.findall('&lt;div class="name"&gt;')
    return urls
  </code></pre>
  
  <p>I've tried this code with both findall and findtext, and either way the result is the same, <strong>"AttributeError: 'str' object has no attribute 'findall'"</strong>. I have confirmed that 'result' is a string with <code>type()</code>. </p>
  
  <p>Am I headed on the right path to extract the URL? How should I address this attribute error?</p>