Access JavaScript variable from a URL using php and regex

Sh Raj - Jun 13 '22 - - Dev Community

I have a link say https://example.com

and the link contents html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">

</head>
<body>
  <br><hr><br>
  <header>
    <h1>Title</h1>
  </header>
<script>
var abc = "https://example2.com/sample.mp4";
</script>

<script>
var poster = "https://example2.com/sample.png";
</script>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

and I want the value of variable abc. That will give me "https://example2.com/sample.mp4" this value.
By grabbing it using file_get_contents('https://example.com') php and getting script data using regex...


And then I will redirect My php page to the variable abc value URL 'https://example2.com/sample.mp4' (here)

How could I do this ?

Stack Overflow

How if anyone knows discuss below !

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .