View Full Version : HTML Placing DIV content from site A into site B
Chappo
April 28th, 2010, 09:28 AM
Hello,
Have been searching for the solution for quite some time now and have not yet found anything that matches what i want to do.
Basically i have 2 sites, for example: www.google.com en www.yahoo.com
On the Google.com site i have a div with content.
Now i want to have that exact div with the content, to be placed in the yahoo.com site.
I have looked at using iFrame before, but i do not want to have the entire google.com site to be displayed, only 1 specific DIV
Is this even possible?
Big thank you in advance
simplistik
April 28th, 2010, 09:54 AM
It's possible, there's an old script called htmlsql that you can target specific elements within a website and extract them as needed. http://www.jonasjohn.de/lab/htmlsql.htm like i said it's old and it's discontinued but it does do a pretty good job. I don't really know an other good method personally.
symmet
April 28th, 2010, 01:29 PM
I would try using jQuery with its load method. You should be able to load in any page you want and then extract the contents of a div, as long as you can target that div by class or ID.
http://api.jquery.com/load/
NeoDreamer
April 28th, 2010, 01:45 PM
Here is a PHP solution. I am going to reverse your example - placing Yahoo into Google, instead of Google into Yahoo because Google uses JS to load its page and PHP can't run JS.
$entirePage = file_get_contents('http://www.yahoo.com');
preg_match('#<h2 class="y-txt-modhdr">(.*?)<#', $entirePage, $matches);
echo 'this is my google site <br />';
echo 'now here is a div from yahoo: ' . $matches[1] . '<br />';
echo 'now we are back on my google site';
The output:
this is my google site
now here is a div from yahoo: MY FAVORITES
now we are back on my google site
psych0mantis00
April 28th, 2010, 02:11 PM
I agree with symmet, jQuery is the simplest you can just pop the div id in the load function and your done
Chappo
April 29th, 2010, 02:05 AM
AWESOME!
I did not know about the Jquery function but will definitely look into it now
Great job guys - thank you so so much! :rich:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.