www.webdeveloper.com
Results 1 to 14 of 14

Thread: iFrame but specific position

  1. #1
    Join Date
    Mar 2010
    Posts
    9

    iFrame but specific position

    Hi,

    I need help
    I wanna create a php code that works like iFrame, but in specific position/area
    The site is "http://www.ecclesia.pt/" and the code is below.
    The part I wanna copy have an id named "textoCentroDireita" (orange)
    In the website is on the right corner below.

    Thanks!

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta name="verify-v1" content="FhbFSOC1778H/FibqDGmIOEA9mao/+8H8n5Xf35gz5U=" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Confer&#234;ncia Episcopal Portuguesa</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link href="/css/layout.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/scripts/depot.js" language="javascript"></script>
    <script type="text/javascript" src="/scripts/swfobject.js" language="javascript"></script>
    <!--[if IE 6]>
    <link href="layoutIE6.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    <!--[if IE 7]>
    <link href="layoutIE7.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    </head>
    <body>
    <div id="Layer0" style="display: none; position: absolute; z-index: 1;"></div>
    <div id="fundoTopo">
    <div id="cabecalho">
    <div id="contactos"><a href="/cep_contactos.shtml"><img src='/imgs/icon_contactos.png' width="20" height="20" border="0"></a></div> <div id="inicio"><a href="/index.shtml"><img src='/imgs/spacer.gif' width="140" height="159" border="0"></a></div>
    <div id="cabecalhoMenuTopo">

    <a href="/cep.shtml" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('ConferenciaEpiscopal','','/imgs/BotaoConferenciaPreto.gif',0)"><img src="/imgs/BotaoConferencia.gif" alt="Confer&#234;ncia Episcopal" name="ConferenciaEpiscopal" width="104" height="31" border="0" id="ConferenciaEpiscopal" /></a>
    <a href="/dioceses.shtml" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Dioceses','','/imgs/BotaoDiocesesPreto.gif',0)"><img src="/imgs/BotaoDioceses.gif" alt="Dioceses" name="Dioceses" width="91" height="31" border="0" id="Dioceses" /></a>
    <a href="/cgi-bin/movimentosobras.pl" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Movimentos','','/imgs/BotaoMovimentosPreto.gif',0)"><img src="/imgs/BotaoMovimentos.gif" alt="Movimentos e Obras" name="Movimentos" width="99" height="31" border="0" id="Movimentos" /></a>
    <a href="/cgi-bin/vidaconsagrada.pl" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('VidaConsagrada','','/imgs/BotaoVidaPreto.gif',0)"><img src="/imgs/BotaoVida.gif" alt="Vida Consagrada" name="VidaConsagrada" width="102" height="31" border="0" id="VidaConsagrada" /></a>
    <a href="/utilitarios.shtml" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Utilitarios','','/imgs/BotaoUtilitariosPreto.gif',0)"><img src="/imgs/BotaoUtilitarios.gif" alt="Utilit&#225;rios" name="Utilitarios" width="99" height="31" border="0" id="Utilitarios" /></a>
    <a href="/cgi-bin/apontadores.pl" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Apontadores','','/imgs/BotaoApontadoresPreto.gif',0)"><img src="/imgs/BotaoApontadores.gif" alt="Apontadores" name="Apontadores" width="101" height="31" border="0" id="Apontadores" /></a> </div>
    <!--cabecalhoMenuTopo -->

    <div id="escolhaEsquema">
    <img src="/imgs/EscolhaEsquema1.gif" alt="Escolher Esquema 1" onclick="mudarFundo(0)" />
    <img src="/imgs/EscolhaEsquema2.gif" alt="Escolher Esquema 2" onclick="mudarFundo(1)" />
    <img src="/imgs/EscolhaEsquema3.gif" alt="Escolher Esquema 3" onclick="mudarFundo(2)" />
    <img src="/imgs/EscolhaEsquema4.gif" alt="Escolher Esquema 4" onclick="mudarFundo(3)" />
    </div>
    <!--escolhaEsquema -->

    </div><!--cabecalho -->

    </div><!--fundoTopo -->

    <div id="fundoPagina">

    <div id="conteudo">

    <div id='conteudoTopo' style='background-image:url(/imgs/FundoConteudoTopo_homepage.gif)'>
    <div id='conteudoTopoImagem'>
    <img src='/cgi-bin/gd_imager.pl?img=bentoxvi_portugal1.jpg&conf=info'/>
    </div><!--conteudoTopoImagem -->
    <div id='conteudoTopoTexto'>
    <p class='titulo3'>Nota Pastoral sobre a Visita do Papa Bento XVI a Portugal<br /></p>
    <div>[<a href="http://www.bentoxviportugal.pt/documentos_ver.asp?noticiaid=54" target="_blank">ver +</a>]</div>
    </div><!--conteudoTopoTexto -->
    <div id='cleardiv1'></div><!--cleardiv1 -->
    </div><!--conteudoTopo -->

    <div id="conteudoCentro">

    <div id="conteudoCentroMenu">


    <iframe SRC="http://www.agencia.ecclesia.pt/widgets/mediabox.shtml" WIDTH="300" HEIGHT='350' FRAMEBORDER='0' MARGINWIDTH='0' MARGINHEIGHT='0' SCROLLING='no'></iframe>

    </div><!--conteudoCentroMenu -->

    <div id="conteudoCentroTexto">


    <div id="textoCentroDireita">
    <div id="liturgiaDoDia">
    <ul>
    <li><img src='/imgs/tituloLiturgia.gif' alt='Liturgia do Dia' /></li>
    <li>
    <img src='/imgs/subtituloAgenda.gif' alt='Agenda Liturgica' /><br />
    <a target='_blank' href="http://www.portal.ecclesia.pt/ecclesiaout/liturgia/liturgia_site/agenda_lit/agenda_ver.asp?cod_agenda=1591">TER&#199;A-FEIRA da semana II</a>
    </li>
    <li>
    <img src='/imgs/subtituloMissa.gif' alt='Celebra&#231;&#227;o da Missa' /><br />
    <a target='_blank' href="http://www.portal.ecclesia.pt/ecclesiaout/liturgia/liturgia_site/lit_dia/fer_fort/ld_fer_fort_ver.asp?cod_fer_fort=83">Missa</a>
    </li>
    <li>
    <img src='/imgs/subtituloSanto.gif' alt='Santo(s) do Dia' /><br />
    <a target='_blank' href="http://www.portal.ecclesia.pt/ecclesiaout/liturgia/liturgia_site/santos/santos_ver.asp?cod_santo=56">S. MARTINHO I, papa e m&#225;rtir</a>
    </li>
    <li>
    <img src='/imgs/subtituloComentario.gif' alt='Coment&#225;rios &#224;s Leituras' /><br />
    18 de Abril de 2010<br /><a href='/cgi-bin/comentario.pl?id=431'>3&#186; Domingo do Tempo Pascal - Ano C</a><br />
    11 de Abril de 2010<br /><a href='/cgi-bin/comentario.pl?id=430'>2&#186; Domingo do Tempo Pascal - Ano C</a><br />
    </li>
    <li>
    <a href='/cgi-bin/apostolado.pl'><img src='/imgs/subtituloApostolado.gif' alt='Apostolado da Ora&#231;&#227;o' border='0' /></a>
    </li>
    </ul>

    </div><!--liturgiaDoDia -->
    </div><!--textoCentroDiteita -->

    <div id='logotipos'>
    <ul>
    <div class='banner'>
    <a href="http://www.agencia.ecclesia.pt" target="_blank"><img src="/banners/agenciaecclesia.gif" border="0" width="100"></a>
    </div>
    <div class='banner'>
    <a href="http://www.ecclesia.pt/programa" target="_blank"><img src="/banners/ecclesia_rtp2.gif" border="0" width="100"></a>
    </div>
    <div class='banner'>
    <a href="http://www.ecclesia.pt/setenta" target="_blank"><img src="/banners/70x7_rtp2.gif" border="0" width="100"></a>
    </div>
    <div class='banner'>
    <a href="http://www.agencia.ecclesia.pt/radio" target="_blank"><img src="/banners/ecclesia_antena1.gif" border="0" width="100"></a>
    </div>
    <div class='banner'>
    <a href="http://www.agencia.ecclesia.pt/anosacerdotal" target="_blank"><img src="/banners/ano_sacerdotal_ecc.gif" border="0" width="100"></a>
    </div>

    </ul>
    </div><!--logotipos -->

    </div> <!--conteudoCentroTexto -->

    <br class='clearfloat'/>
    </div><!--conteudoCentro -->

    </div><!--conteudo -->

    <div id="rodape">

    <div id="copyright"><p>&copy;2009, Confer&#234;ncia Episcopal Portuguesa, todos os direitos reservados.</p></div><!--copyright -->

    <div id="webdesign"><p><a href='http://www.terradasideias.com' target="_blank">Design e Programa&#231;&#227;o: Terra das Ideias</a></p></div><!--webdesign -->
    <br class='clearfloat'/>
    </div><!--rodape -->

    <div id="cleardiv2"></div><!--cleardiv2 -->

    </div><!--fundoPagina -->

    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("&#37;3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-1208693-20");
    pageTracker._trackPageview();
    } catch(err) {}</script>

    </body>
    </html>

  2. #2
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    Um, PHP code generates the HTML to create an iframe tag, not sure what you meant by PHP that works "like an iframe".

    This CSS alternative solution involves you simply creating a style sheet or adding styles to your current page, directly or via PHP outputting the following:

    Untested, something similar to this (you edit to customize):

    HTML Code:
    div#textoCentroDireita {
    
    position: absolute;
    top: 20px;
    left: 30px;
    width: 800px;
    height: 400px;
    background-color: white;
    overflow: scroll;
    
    }
    I just set your div position absolutely (you adjust the offsets), set a width and height like you'd do for an iframe, white background which is typical for many iframes, and scrollbars on overflow which is typical for iframes as well. Feel free to add borders and other styles as you see fit to adjust look and feel.

    This is simple, sure, but get the idea? I hope this is what you're asking!

    -jim

  3. #3
    Join Date
    Mar 2010
    Posts
    9
    Sorry I am portuguese

    In HTML iFrame you can print the whole page, from another server, to your own webpage, right?
    So, I want that, but I wanna only a specific area from this server and not whole page.
    The page change that specific area everyday and it is why I wanna that specific area.

    The specific area I want is from the website "http://www.ecclesia.pt" (it's not my own website)

    Thanks!

    Quote Originally Posted by SrWebDeveloper View Post
    Um, PHP code generates the HTML to create an iframe tag, not sure what you meant by PHP that works "like an iframe".

    This CSS alternative solution involves you simply creating a style sheet or adding styles to your current page, directly or via PHP outputting the following:

    Untested, something similar to this (you edit to customize):

    HTML Code:
    div#textoCentroDireita {
    
    position: absolute;
    top: 20px;
    left: 30px;
    width: 800px;
    height: 400px;
    background-color: white;
    overflow: scroll;
    
    }
    I just set your div position absolutely (you adjust the offsets), set a width and height like you'd do for an iframe, white background which is typical for many iframes, and scrollbars on overflow which is typical for iframes as well. Feel free to add borders and other styles as you see fit to adjust look and feel.

    This is simple, sure, but get the idea? I hope this is what you're asking!

    -jim

  4. #4
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    Okay, I follow you now.

    In PHP, you can use cURL, fopen() or file_get_contents() - plenty of options.

    PHP Code:
    $data file_get_contents("http://www.ecclesia.pt/");
    print 
    $data
    PHP Code:
    $f fopen("http://www.ecclesia.pt/""r");
    $data=''
    while(!
    feof($f)) 
        
    $data.=fread($f,$size); 
    fclose($f); 
    print 
    $data
    Some hosts don't allow the above, and if your PHP supports cURL not only does this do the same but there are many more powerful options to control its behavior and output.

    PHP Code:
    $ch curl_init();
    curl_setopt($ch,CURLOPT_URL,"http://www.ecclesia.pt/");
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
    $data curl_exec($ch);
    curl_close($ch);
    print 
    $data
    You can use any of these methods (simplified examples, up to you to customize) to get the data from the remote site and populate an actual iframe, a div, whatever, and filter out the HTML from $data that you don't want to include (hint: use preg_match to pull the HTML only between and including the opening and closing div tags with that unique ID "textoCentroDireita" , easy enough).

    Go to PHP.NET and research these various commands and happy coding!

    -jim
    Last edited by SrWebDeveloper; 04-13-2010 at 04:25 PM. Reason: adjusted code block

  5. #5
    Join Date
    Nov 2008
    Posts
    2,477
    Since this document is purportedly XHTML, you should also be able to use the DOM extension to get your data, which may or may not be easier than using regular expressions depending on how comfortable you are with them. However there is no guarantee that the document is actually well-formed. The javascript block without CDATA tags sets alarm bells ringing for a start!
    The first rule of Tautology Club is the first rule of Tautology Club.

  6. #6
    Join Date
    Dec 2010
    Posts
    5

    Try to only show a part

    I'm trying what here is standing. And get the compleet page loaded.
    How do i just get the part between
    Code:
    <form id="frmaanbiedingen" name="frmaanbiedingen" action="print.asp" method="get" target="_blank">
    
    <table class="contentdatagrid" align="center" cellspacing="0">
      
    ... the code ...
      
    </tbody></table>
    
    </form>
    The thing that I now use is
    Code:
    <?php
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,"http://www.example.com/nucontroller.asp?portalid=1&navid=43&lcid=nl");
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
    $data = curl_exec($ch);
    curl_close($ch);
    print $data; 
    ?>
    so what do I need to add to just show that part.

    thank you
    Dennis

  7. #7
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    PHP Code:

    <form id="frmaanbiedingen" name="frmaanbiedingen" action="print.asp" method="get" target="_blank">

    <table class="contentdatagrid" align="center" cellspacing="0">
      
    <?php
    $ch 
    curl_init();
    curl_setopt($ch,CURLOPT_URL,"http://www.example.com/nucontroller.asp?portalid=1&navid=43&lcid=nl");
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
    $data curl_exec($ch);
    curl_close($ch);
    print 
    $data
    ?>
      
    </tbody></table>

    or

    PHP Code:
    <?php
    $ch 
    curl_init();
    curl_setopt($ch,CURLOPT_URL,"http://www.example.com/nucontroller.asp?portalid=1&navid=43&lcid=nl");
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
    $data curl_exec($ch);
    curl_close($ch);
    ?>

    <html>
    <head></head>
    <body>

    <form id="frmaanbiedingen" name="frmaanbiedingen" action="print.asp" method="get" target="_blank">

    <table class="contentdatagrid" align="center" cellspacing="0">

    <?php echo $data?>

    </tbody></table>
    </body>
    </html>
    or

    PHP Code:

    <?php
    function curl_this($opt) {

        
    $ch curl_init();
        
    curl_setopt_array($ch$opt);
        
    $data curl_exec($ch);

    curl_close($ch);

    return 
    $data;
    ?>


    <html>
    <head></head>
    <body>

    <form id="frmaanbiedingen" name="frmaanbiedingen" action="print.asp" method="get" target="_blank">

    <table class="contentdatagrid" align="center" cellspacing="0">

    <?php
    $params 
    = array(
                
    CURLOPT_URL => 'http://www.example.com/nucontroller.asp?portalid=1&navid=43&lcid=nl'
                
    CURLOPT_RETURNTRANSFER => 1
                
    CURLOPT_POST => 0
                
    CURLOPT_POSTFIELDS => '',
                
    CURLOPT_CONNECTTIMEOUT,10,
        );
        
    echo 
    curlThis($params);
    ?>

    </tbody></table>
    </body>
    </html>
    Edit: Why on gods green earth are you using php AND asp? I smell conflicts......

    ... dingen" action="print.asp" method="get" tar ....
    Last edited by ehime; 12-08-2010 at 01:45 PM.
    _,-O
    O
    (_)) ubuntu -
    -`-O

  8. #8
    Join Date
    Dec 2010
    Posts
    5

    Why php and asp

    First you get the wrong picture of my question (And thats my fold ;-) )

    The thing that I want is to get a part off a complete page. So that I won't see the navigation and other things.
    It need to get updated every Monday. So that i get the right advertisements.

    So if I just load the page whit this command I got always the right advertisements. Thats my thinking

    The only thing what I could think of is to use php (I only can write html pages)
    So I make a php file whit this code and insert it in my joomla site. I'm thinking to do this whit wrapper (iframe extension from joomla)

    If you or somebody else got another idea then please make it forward.

    I'm using joomla 1.5

  9. #9
    Join Date
    Dec 2010
    Posts
    5
    Is there still someone who can help me?
    My code is now:
    Code:
    <?php
    //lookup the url
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL,"http://www.example.com/nucontroller.asp?portalid=1&navid=43&lcid=nl");
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
    $curl = curl_exec($ch);
    //replace words that it wil look right
    $string = $curl;
    $pattern[0] = '/src="/';
    $pattern[1] = '/href="/';
    $pattern[3] = '/input/';
    $replacement[0] = '/src="http://www.example.com//';
    $replacement[1] = '/href="http://www.example.com//';
    $replacement[3] = '/ /';
    $replace = preg_replace($pattern, $replacement, $string);
    curl_close($ch);
    echo $replace;
    ?>
    Ho does it only show the page between the line´s:
    Code:
    <form id="frmaanbiedingen" name="frmaanbiedingen" action="print.asp" method="get" target="_blank">
    
    <table class="contentdatagrid" align="center" cellspacing="0">
      
    ... the imported part ...
      
    </tbody></table>
    
    </form>
    I keep on trying with filter and prog_match, but nothing work. At least I don;t know how they work.
    Does anyone have an answer

  10. #10
    Join Date
    Jan 2009
    Posts
    3,346

  11. #11
    Join Date
    Dec 2010
    Posts
    5
    Quote Originally Posted by criterion9 View Post
    I don't think there is a extension that iframe/ copy a website and then only a little part.

  12. #12
    Join Date
    Oct 2008
    Location
    Seattle, Wa
    Posts
    695
    If you want to learn how to scrape a website I
    really suggest you either hire someone or learn
    php yourself. Page scrapping will break when
    even the LITTLEST things on the original page
    are altered
    _,-O
    O
    (_)) ubuntu -
    -`-O

  13. #13
    Join Date
    Jan 2009
    Posts
    3,346
    Quote Originally Posted by dennis1986 View Post
    I don't think there is a extension that iframe/ copy a website and then only a little part.
    You'll need to perform the scrape yourself unless you can get a hold of an exposed API (which for advertising you'd think they would be all for making it easier).

  14. #14
    Join Date
    Dec 2010
    Posts
    5
    There is no changing the website only between these line. Every week there is standing something different, but in the same way.

    If they are going to change it i will notice.

    But I keep on reading php I don't give up.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles