0

lots of results on this forum, $temp = file_get_contents('http://example.com/weather/javascriptfile.js'); echo "document.writeln(obTemperature);";

the javascriptfile.js contains

var obTemperature = "55";
var obIconCode = "01";

but this only works if the page loads, the javascript file is already loaded into memory,

  • i dont see how that code could possibly work you do noting with `$temp` for a start –  Dec 13 '16 at 21:27
  • What result are you trying to achieve? What exactly do you think `var obTemperature = echo $obTemperature;` does? – Patrick Q Dec 13 '16 at 21:28
  • and if that close doesn't suit, well then... you'll know what to do. – Funk Forty Niner Dec 13 '16 at 21:29
  • a scaping js file answer: http://stackoverflow.com/questions/5951395/extracting-javascript-variable-values-via-web-scraping –  Dec 13 '16 at 21:30
  • you can try with regex and the preg_match() php function. $input = file_get_contents('http://example.com/weather/javascriptfile.js'); preg_match("/var (.*) = \"(.*)\";/", $input, $output); the output array should look something like this : array( 0 => 'var obTemperature = "55";' 1 => '0bTemperature' 2 => '55' ) The regex can be improved, this is for the idea ;) – rudak Dec 13 '16 at 21:37
  • $temp was read from _GET solution on stackoverflow not working – DOMDocumentVideoSource Dec 13 '16 at 21:41
  • Patrick, just reading obTemperature value from device for safety monitor for my village as we have no climate controlled spots and people are dying, – DOMDocumentVideoSource Dec 13 '16 at 21:42
  • yheah @PatrickQ stop killing the villagers ;) –  Dec 13 '16 at 21:44

0 Answers0