Using xpath to extract date
<p>I'm trying to extract the date from a webpage, '07/18/16' in the comment below. I'm not clear on the syntax for xpath, how would you grab just the date?</p>

<pre><code>#&lt;p&gt;Opened &lt;a class="timeline" href="/trac3/timeline?from=2016-07-    
#18T14%3A46%3A43-04%3A00&amp;amp;precision=second" title="See timeline at   
#07/18/16 14:46:43"&gt;6 weeks ago&lt;/a&gt;&lt;/p&gt;

from lxml import html
import requests

page = requests.get(webpage)
tree = html.fromstring(page.content)

openDate = tree.xpath('//Opened/text()')

print 'Open Date: ', openDate
</code></pre>

<p>Like this?</p>

<pre><code>import re
from lxml import html

data = """&lt;p&gt;Opened &lt;a class="timeline" href="/trac3/timeline?from=2016-07-18T14%3A46%3A43-04%3A00&amp;amp;precision=second" title="See timeline at 07/18/16 14:46:43"&gt;6 weeks ago&lt;/a&gt;&lt;/p&gt;"""

tree = html.fromstring(data)
try:
    href = tree.xpath("//a[@class='timeline']/@href")[0]
    openDate = re.search(r'from=(\d+-\d+-\d+)', href).group(1)
    print('Open Date: ', openDate)
    # Open Date:  2016-07-18
except:
    print("Something went wrong")
</code></pre>

<p>This grabs the <code>@href</code> attribute first, then analyzes it with a regular expression.
<hr>
Having read the question again, you might rather look for the <strong>title attribute</strong>:</p>

<pre><code>try:
    href = tree.xpath("//a[@class='timeline']/@title")[0]
    openDate = re.search(r'\d+/\d+/\d+', href).group(0)
    print('Open Date: ', openDate)
    # Open Date:  07/18/16
except:
    print("Something went wrong")
</code></pre>

python regex xpath python-requests lxml