Inserting a portion of code from another page
Posted: Mon Apr 26, 2010 10:44 pm
Hello!
I am trying to solve a problem on how to insert a part of the code of an external web page into my php file. Tutorials handle this function with starting point and length, but because the external web page change frequently there is the need to use a string as point to mark the beginning and the end of the useful code section. Let's take an example with the google page.
"(...)" are omission to shorten the code display
In this example the useful secton that need to be inserted into the php file is
Everything before
and after
should be omitted. The end of the first omitted part, the beginning of the second omitted part and the beginning and the end of the useful part are unique and never change, so that they could be used to identify the entry and exit point.
Any idea where I can find a working example?
Thanks in advance!
I am trying to solve a problem on how to insert a part of the code of an external web page into my php file. Tutorials handle this function with starting point and length, but because the external web page change frequently there is the need to use a string as point to mark the beginning and the end of the useful code section. Let's take an example with the google page.
"(...)" are omission to shorten the code display
Code: Select all
<!doctype html><html onmousemove="google&&google.fade&&google.fade(event)"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>Google</title><script>
(...)
<div class=gbh style=left:0></div><div class=gbh style=right:0></div></div> <center><span id=body><center><br clear=all id=lgpd><img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276 id=logo onload="window.lol&&lol()"><br><br><form action="/search" name=f onsubmit="if(document.f.action=='http://www.google.com/images'&&location.hostname!='images.google.com')document.f.action='/images'" onsubmit="google.fade=null"><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%> </td>
(...)
ad",l,false);else if(window.attachEvent)window.attachEvent("onload",l);google.timers.load.t.prt=(f=(new Date).getTime());
})();
</script>
Code: Select all
<img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276 id=logo onload="window.lol&&lol()"><br>
Code: Select all
...ter><span id=body><center><br clear=all id=lgpd>
and after
Code: Select all
<br><form action="/search" name=f onsubmit...
should be omitted. The end of the first omitted part, the beginning of the second omitted part and the beginning and the end of the useful part are unique and never change, so that they could be used to identify the entry and exit point.
Any idea where I can find a working example?
Thanks in advance!