0

How to display other sites content in our site and server without using iframe? In fact, I'm going download a page (same domain) and display in my server via php like browsers.

Note: file_get_contents works well, but "CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource" so all stylesheets and some images are not loaded.

Is there a way to do it?

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
lock
  • 711
  • 3
  • 9
  • 19
  • Technically it might be possible. But it won't be easy. First you use `file_get_contents()` to get the page source. Then you use [DOMDocument();](http://php.net/manual/en/domdocument.loadhtml.php) to process the HTML. Find all the css and image links inside the HTML. Download each of those files and hope they aren't blocking direct links (hot linking). Then rebuild the HTML replacing the links to the files you've downloaded on your own server. As I said: It's a lot of work and long shot to get it working perfectly. But it's all I can think of. – icecub Nov 26 '16 at 20:20

1 Answers1

0

I think in PHP you can't do this, because some website header block access for you. I would do this in js/jquery like this:

Ajax/jQuery - Load webpage content into a div on page load?

Community
  • 1
  • 1
bradley546994
  • 630
  • 2
  • 12
  • 30