import lxml.html
from collections import namedtuple
s = """
Release | REFDB | URL |
3.7.3 | 12345 | http://google.com |
3.7.4 | 456789 | http://foo.com |
3.7.5 | 151515 | http://foo.com |
"""
def info_gen(rows):
info = namedtuple('info', ['Release', 'REFDB', 'URL'])
for row in rows:
yield info(*row.xpath('.//text()'))
html = lxml.html.fromstring(s)
rows = html.xpath('//table//tr[td]')
Release = input("Enter Release:")
for info in info_gen(rows):
if Release in info:
print(info)
break
out:
Enter Release:3.7.5
info(Release='3.7.5', REFDB='151515', URL='http://foo.com')