Is there a way to frame a certain portion of a website? Say I was trying to extract data for a site, but did not want to frame their navigation, but also I was unable to extract the data using php, could I frame a certain portion on their site. PS: I have permission to do both, extract the data via php (I have no idea how to do this) or frame the information. I can frame the entire page, but I want to only frame a small portion. Let me know if you can help. Thanks.
I assume that the first page is not a frame? If that is the case with framing you could size the frame to the size of that portion that you want and then place the page in the frame using absolute cords and no scrolling which would not show the nav.
Using php, simply open the page as a variable, then delete the part you don't need from the variable rather than doing anything with the webpage, then call php script ECHO "$variable"; anywhere where you need the page, done.
whoops... one more thing... if the page you are extracting the data from is located on a different server, the script will be rather slow, as it'll load the WHOLE page content every time it is called. To prevent that, you could try caching the site (assuming it doesn't change frequently) by first writing the page (in $variable) into a file on your own server and either load it through php or by SSI from there. Then make a cron job for extracting and caching the page once in a while, depending on how often it changes.
This phrase worries me "but did not want to frame their navigation", your not pinching content are you? Deep linking content like that without permission is illegal without permission.
OWG, If you had read my entire post you would have seen that I have permission. As for the php, my skills are weak so for me to do that I think it is going to take some time. I thought it would be easier for me to just frame it, but I only want to frame a certain portion.
If you want the content of this frame to look exactly as it looks in the original website and without publishing the entire page, it may be a heck of a job to extract just the info you need, considering all styles, inheritance, etc (e.g. if their article font properties are inherited from an element participating in the navigation menu creation, throwing away navigation menu will change the article font). I don't think there's a generic way to do this without actually parsing HTML/CSS. You can probably experiment with a clip region in CSS. For example, you could try to get all of their page, but show only the main content part - the navigation menu and their headers would be hidden. I suspect that navigating such page would be difficuit (e.g. their scroll bars vs your scroll bars, etc). Of course, much depends on the content - if it's mostly text, it's probably fairly easy to reformat it using your server-side scripts. If it's a complex mix of formatted text and graphics, you may need to do something tricky, like clipping or parsing. J.D
Thanks JD, I previously sent you a PM about what I was trying to do. I have now sent you a similar one to the one I sent Foxy. I thought there would be a simple solution on the web, but I have found nothing.
Solution for php (quite easy ): <?php $sourcepage = "http://www.pageyouwanttoframe.com"; $tempfilename = "tmp/page$j.html"; //make writeable (777) directory /tmp before running script $targetdirectory = "http://www.placeonyourserverwhereyouwanttocachethepage.com"; $targetfilename = "cache.html"; $dynamic_source = fopen($sourcepage, 'r'); mkdir("$targetdirectory", 0777); $tempfile = fopen($tempfilename, 'w'); while (!feof($dynamic_source)) { $htmldata .= fread($dynamic_source, 8192); } fclose($dynamic_source); $htmldata = preg_replace(...//HERE YOU NEED TO SUBSTRACT WHAT YOU WANT TO REMOVE FROM YOUR FRAMED SITE (NOW STORED IN VARIABLE $htmldata), YOU CAN DO THIS WITH THE preg_replace COMMAND, READ MORE ABOUT AT www.php.net/manual/en/function.preg-replace.php // $tempfile = fopen($tempfilename, 'w'); fwrite($tempfile, $htmldata); fclose($tempfile); copy($tempfilename, $targetfilename); unlink($tempfilename); ?> Where you want to display the "framed" content, call a php script that reads the content of $targetfilename and displays it, eg. <?php $sourcepage = "http://www.placeonyourserverwhereyouwanttocachethepage.com"; $framedcontent = fopen($sourcepage, 'r'); echo "$framedcontent"; fclose($sourcepage); ?>
Newcomputer, I need something like that done on one of my sites. Couldn't find a way to do it either. If you manage to do it, please get in touch with me, I would be happy to pay you for helping me out. Thanks!
Careful with pulling content from other sites and serving it off your server - make sure that under no circumstances you actually execute their code (e.g. if you pull unprocessed PHP, your server must not execute it - it should either filter out such code or serve it as-is). J.D.
Smart Links, Do you know where. I have just looked through and I see nothing. I have DWMX 2004, if that helps...