Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get page from external server

I want to pass a function a string, which takes that string tacks it onto url. Then goes to that url and then returns the page to my server so I can manipulate it with JS.

Any Ideas would be much appreciated.

cheers.

like image 329
joepour Avatar asked Jan 19 '26 09:01

joepour


1 Answers

If your fopen_wrappers are enabled, you can use file_get_contents() to retrieve the page, and then insert JavaScript into the content before echoing it as output.

$content = file_get_contents('http://example.com/page.html');
if( $content !== FALSE ) {
  // add your JS into $content
  echo $content;
}

This of course won't affect the original page.

like image 92
Jeff L Avatar answered Jan 21 '26 22:01

Jeff L



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!