Created
January 31, 2022 11:56
-
-
Save Sieboldianus/bfc3300a8e2adf0882143ed352d4c814 to your computer and use it in GitHub Desktop.
Stackoverflow as iframe with php file_get_contents();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html><html> | |
<?php | |
$url = 'https://stackoverflow.com/questions/5710867/downloading-and-unzipping-a-zip-file-without-writing-to-disk&noredirect=1'; | |
$site = file_get_contents($url); | |
$site = preg_replace('#<div class="ff-sans ps-fixed z-nav-fixed ws4 sm:w-auto p32 sm:p16 bg-black-750 fc-white bar-lg b16 l16 r16 js-consent-banner">(.*?)</div>#s', ' ', $site); | |
$site = preg_replace('~<\s*\bscript\b[^>]*>(.*?)<\s*\/\s*script\s*>~is', ' ', $site); | |
echo $site | |
?> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I recently had to include an iframe of stackoverflow into an interactive presentation for illustrating purposes. However, stackoverflow contains code and tracking that prevents including any page in an iframe.
Modify the url and upload the above
iframe.php
to any php capable public server. Reference the newindex.php
as your iframe, instead of directly linking to stackoverflow.Note that for security reasons, I added the url as a static parameter.