/    Sign up×
Community /Pin to ProfileBookmark

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!

[QUOTE]

<!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”>

[COLOR=”Orange”][COLOR=”DarkOrange”]<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 –>
[/COLOR][/COLOR]
<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>

[/QUOTE]

to post a comment
PHP

13 Comments(s)

Copy linkTweet thisAlerts:
@SrWebDeveloperApr 13.2010 — 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):

[code=html]div#textoCentroDireita {

position: absolute;
top: 20px;
left: 30px;
width: 800px;
height: 400px;
background-color: white;
overflow: scroll;

}[/code]


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
Copy linkTweet thisAlerts:
@aliengodauthorApr 13.2010 — Sorry I am portuguese :p

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! ?

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):

[code=html]div#textoCentroDireita {

position: absolute;
top: 20px;
left: 30px;
width: 800px;
height: 400px;
background-color: white;
overflow: scroll;

}[/code]


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[/QUOTE]
Copy linkTweet thisAlerts:
@SrWebDeveloperApr 13.2010 — Okay, I follow you now. ?

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

[code=php]$data = file_get_contents("http://www.ecclesia.pt/");
print $data;[/code]


[code=php]$f = fopen("http://www.ecclesia.pt/", "r");
$data='';
while(!feof($f))
$data.=fread($f,$size);
fclose($f);
print $data;
[/code]


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.

[code=php]$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;[/code]


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
Copy linkTweet thisAlerts:
@MindzaiApr 14.2010 — 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!
Copy linkTweet thisAlerts:
@dennis1986Dec 08.2010 — 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>[/CODE]


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;
?>[/CODE]


so what do I need to add to just show that part.

thank you

Dennis
Copy linkTweet thisAlerts:
@ehimeDec 08.2010 — [code=php]

<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>
[/code]



or

[code=php]
<?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>
[/code]


or

[code=php]

<?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>
[/code]


[color=red]Edit:[/color] Why on gods green earth are you using php AND asp? I smell conflicts......

... dingen" [b]action="print.asp"[/b] method="get" tar .... [/quote]
Copy linkTweet thisAlerts:
@dennis1986Dec 08.2010 — 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) :rolleyes:

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

I'm using joomla 1.5
Copy linkTweet thisAlerts:
@dennis1986Dec 08.2010 — 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;
?>
[/CODE]

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>[/CODE]


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
Copy linkTweet thisAlerts:
@dennis1986Dec 08.2010 — http://extensions.joomla.org/[/QUOTE]
I don't think there is a extension that iframe/ copy a website and then only a little part.
Copy linkTweet thisAlerts:
@ehimeDec 08.2010 — 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
Copy linkTweet thisAlerts:
@criterion9Dec 08.2010 — I don't think there is a extension that iframe/ copy a website and then only a little part.[/QUOTE]

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).
Copy linkTweet thisAlerts:
@dennis1986Dec 08.2010 — 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.
×

Success!

Help @aliengod spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...