Framing a certain portion of a website?

Discussion in 'HTML & Website Design' started by NewComputer, Feb 18, 2005.

  1. #1
    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.
     
    NewComputer, Feb 18, 2005 IP
  2. Foxy

    Foxy Chief Natural Foodie

    Messages:
    1,614
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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. :)
     
    Foxy, Feb 18, 2005 IP
  3. ChinaNick

    ChinaNick Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    ChinaNick, Feb 19, 2005 IP
  4. ChinaNick

    ChinaNick Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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.
     
    ChinaNick, Feb 19, 2005 IP
  5. Old Welsh Guy

    Old Welsh Guy Notable Member

    Messages:
    2,699
    Likes Received:
    291
    Best Answers:
    0
    Trophy Points:
    205
    #5
    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.
     
    Old Welsh Guy, Feb 19, 2005 IP
  6. NewComputer

    NewComputer Well-Known Member

    Messages:
    2,021
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    188
    #6
    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.
     
    NewComputer, Feb 19, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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
     
    J.D., Feb 19, 2005 IP
  8. NewComputer

    NewComputer Well-Known Member

    Messages:
    2,021
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    188
    #8
    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.
     
    NewComputer, Feb 19, 2005 IP
  9. ChinaNick

    ChinaNick Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    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);
    ?>
     
    ChinaNick, Feb 21, 2005 IP
  10. NewComputer

    NewComputer Well-Known Member

    Messages:
    2,021
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    188
    #10
    Wow,

    Thanks ChinaN. I will have a look today.
     
    NewComputer, Feb 21, 2005 IP
  11. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #11
    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!
     
    fryman, Feb 21, 2005 IP
  12. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #12
    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.
     
    J.D., Feb 21, 2005 IP
  13. Old Welsh Guy

    Old Welsh Guy Notable Member

    Messages:
    2,699
    Likes Received:
    291
    Best Answers:
    0
    Trophy Points:
    205
    #13
    New Computer, your right, and I am sorry for casting doubt on your integrity :(
     
    Old Welsh Guy, Feb 21, 2005 IP
  14. NewComputer

    NewComputer Well-Known Member

    Messages:
    2,021
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    188
    #14
    No problems OWG
     
    NewComputer, Feb 21, 2005 IP
  15. Smart Links

    Smart Links Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    dreamweaver mx has a great tutorial on this maneuver.
     
    Smart Links, Feb 21, 2005 IP
  16. NewComputer

    NewComputer Well-Known Member

    Messages:
    2,021
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    188
    #16
    Smart Links,

    Do you know where. I have just looked through and I see nothing. I have DWMX 2004, if that helps...
     
    NewComputer, Feb 22, 2005 IP