There is a date and time, dynamic, updated on the site constantly. I get their parser through xpath. How now is the resulting value compared with the current date and time, and if the current time is more than 5 minutes for example. That performs for example print. In general, the essence of the task, the hardware parser, which is constantly monitored and displayed on html in the form of time and date.

import requests import datetime from lxml import html response = requests.get('URL') parsed_body = html.fromstring(response.text) a = 'hostname' now = datetime.datetime.now() now1 = now.strftime("%d.%m.%Y %H:%M:%S") b = (str(parsed_body.xpath('/html/body/table/tbody/tr[001]/td[1]/text()'))) c = (str(parsed_body.xpath('/html/body/table/tbody/tr[001]/td[2]/text()'))) print(a + b + c) 
  • They would bring in which variable you pull out the time and what is the value in it - gil9red
  • What is your difficulty? Is it clear how to turn a string into datetime? Is it clear how to compare datetime and how to add 5 minutes? ru.stackoverflow.com/q/659229/23044 - jfs
  • I pull out the time, as I already say through xpath, it is displayed in this form: ['25 .10.2017 10:29:28 '] just like that, with quotes and brackets. That is, if you look at the code as a matter of fact: s = ['25 .10.2017 10:29:28 '] - sakhalin

0