There is such code on php and js:

<script src="js/jquery-3.2.1.min.js"></script> <?php echo file_get_contents('https://www.gismeteo.ru/weather-saratov-5032/'); ?> <script> $(document).ready(function(){ var wth = $(".tab-weather__value_l").text(); var str = wth.replace(/\s/g, ''); var ifminus = str.search( /^(?!-)\D*/ ); if (ifminus === 0) { var plusint = str.replace( /^(?!-)\D*/, ""); var plusint = plusint.replace( /\,/, "."); var plusint = plusint - plusint - plusint; console.log(plusint); } console.log(wth); console.log(str); console.log(ifminus); console.log("WATCH HERE"); console.log(parseFloat(plusint, 10)); console.log("WATCH HERE_2"); if (plusint > 0) { console.log("WORKING"); } else { console.log("UPS");} }); </script> <p>Checking</p> 

He displays the entire page of another site at his place, and there he searches for what he needs, and successfully finds ... I just do not need the display of this whole page, but I did not invent anything smarter than creating a div under it and hide it. Tell me, maybe there is a more civilized method?

  • You have designated curl as one of the subject matter tags. Why not use? - Kirill Korushkin
  • I really can't understand him, I thought he might be told here - Paul Wall
  • one
    why do you need curl if you already got the page through file_get_contents ? take simple-html-dom or analogs, and pull out the data. but it is better to get this data through CZK and save it somewhere. - teran
  • one
    and look at the informers in general gismeteo.ru/informers , mb with their help it will be easier to solve the problem - teran

1 answer 1

It was possible to reduce the output part to 1 div, so in fact, everything works =)

 <?php $html = file_get_contents('https://www.gismeteo.ru/weather-saratov-5032/'); $first_step = explode( 'tab-weather__value_l">' , $html ); $second_step = explode("</div>" , $first_step[1] ); echo '<div style="display:none" id="cc">'.$second_step[0].'</div>'; ?> <script> $(document).ready(function(){ var wth = $("#cc").text(); var str = wth.replace(/\s/g, ''); var ifminus = str.search( /^−/ ); if (ifminus === 0) { var plusint = str.replace( /^−/, ""); var plusint = plusint.replace( /\,/, "."); var plusint = plusint - plusint - plusint; } else { var plusint = str; var plusint = plusint.replace( /\,/, "."); } var rw = parseFloat(plusint, 10); if (rw < -15) { $("#weather").html("<div style='color:red'>Монтаж запрещен</div>"); } else { $("#weather").html("<div style='color:green'>Монтаж разрешен</div>"); } }); </script> <div id="weather">Problem Detected</div>