from lxml import html import requests # Request the page try: page = requests.get('https://wiki.limbosolutions.com/index.php/P%C3%A1gina_principal', timeout=2) # Parsing the page # (We need to use page.content rather than # page.text because html.fromstring implicitly # expects bytes as input.) tree = html.fromstring(page.content) # Get element using XPath buyers = tree.xpath('string(//html//head//meta//@content)') print("{\"status\":\"On\",\"version\":\"" + buyers + "\"}") except: print("{\"status\":\"error\"}")