title: extract href values containing keyword using XPath in python
body: <p>I know variants of this question have been asked a number of times but I've not been able to crack it and get what I want.</p>
  <p>I have a <a href="http://www.wildwinds.com/coins/ric/constantine/t.html" rel="nofollow noreferrer">website</a> which has a few tables in it. The table of interest contains a column where each row contains the word <code>Text</code> hyperlinked to a different page. Here is a specific example from the first row on the above linked page:</p>
  <pre><code>&lt;a href=&quot;_alexandria_RIC_VI_099b_K-AP.txt&quot;&gt;Text&lt;/a&gt;
  </code></pre>
  <p>This is the general pattern:</p>
  <pre><code>&lt;a href=&quot;_something_something-blah-blah.txt&quot;&gt;Text&lt;/a&gt;
  </code></pre>
  <p>Right now I'm doing this:</p>
  <pre><code>import requests  
  import lxml.html as lh
  page = requests.get(&quot;http://www.wildwinds.com/coins/ric/constantine/t.html&quot;)
  doc = lh.fromstring(page.content)
  href_elements = doc.xpath('/html/body/center/table/tbody/tr/td/a/@href')
  print(href_elements)
  </code></pre>
  <p>The desired response should be an array of items looking like this: <code>_something_something-blah-blah.txt</code> What I get is an empty array.</p>
  <p>Since the page has other href elements I'm not interested in, I also want to modify the query to only grab the href elements that contain <code>.txt</code> in their values.</p>
  <p>Any help you can provide is much appreciated!</p>