I am looking to draw in information from another website into my website.
The other website has this information within a table, I cannot edit the other site at all so can only get the information from it but wish to have parts of that information on my website. Its jst basic data.
Im currently trying this with an iFrame. Heres an example of what I am doing:
<iframe id="IDNAME" class="news-rss" src="URL HERE" this.getElementsByTagName('html')[0].id;><p>Your browser does not support iframes.</p></iframe>
Is there anything im doing wrong or another way around this maybe not using iFrames? Please help? Thank you in advance.
Ps. I have full consent to use the information on my website.
Granted that my understanding is correct - I'd suggest you to see if that site offers some form of a RSS feed. There are plenty of dynamic RSS display scripts, which you can use to show within your site information from another site. The major benefit is the ability to customize it, rather than rely on whatever is in that iFrame.
//Replace any stuff you don't want here...
$page = preg_replace('/<span/', "<!-- <span", $page); // This will make a span tag invisible.
$page = preg_replace('/<\/span>/', "<\/span> -->", $page); // This makes a closing span tag invisible.
$page = preg_replace('/<a /', "<a rel=\"nofollow\" ", $page); // This makes all their hyperlinks nofollow
$test = explode('<table',$page);
for($t=1;$t<=count($test)-2;$t++){ // count how many closing table tags from the bottom you want and enter it here
print "<table";
print $test[$t];
}
?>
print "</table>";
</body>
</html>
Using cURL:
PHP Code:
<!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 http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Your Title</title>
<base href="http://astore.amazon.com/gps-with-bluetooth-20?_encoding=UTF8&node=1"> <!-- This sets all links to the proper URL (optional) -->
</head>
<?php
$url = "http://astore.amazon.com/gps-with-bluetooth-20?_encoding=UTF8&node=1";
$page = file_get_contents("http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html");
// Replace the URL above with the one you want to scrape.
// For you the $getpage should be the entire html you display on the page
$explodefirst = explode('<div class="forextable">',$page); //Enter the starting piece of html you want to grab here...
$headerisgone = $explodefirst[1];
$explodesecond = explode('</div>',$headerisgone); // Enter the ending piece of HMTL here
$endresult = $explodesecond[0];
/*
$endresult = str_replace('href="/','target="_blank" href="http://www.ecb.int/stats/exchange/eurofxref/html/', $endresult); // Makes links work in a new tab or window
*/
print '<div class="forextable">'; // Put back the starting HTML you grabbed...
print $endresult; //This prints your scrape
print '</div>'; // Put back the ending HTML here...
?>
Now, say you want to put this on your page in an iframe.
Copy the above and put it on your server in a file called, say:
scrape.php
Then either use PHP Include, or put that file into an iframe. PHP include is better as then search engines will find it and see it as content.
Thanks for the reply LiveCity and Donatello.
The site doesn't have an RSS feed option. Donatello, those are great but I have gone with the iFrame option for now.
Now I have a new problem. The site I am getting the data from automatically refreshes its page to update the information on the page constantly. When you are on my page with that showing up in the iframe, within seconds its refreshes to that site. Is there a way to keep it from not refreshing, reminding you that I cannot change anything on that site, but maybe something on my site where as I can have a bit of js that will stop it refrehing? any ideas, all new ideas welcome. Thank you in advance.
Bookmarks