我想要将外部网页的特定Div加载到我自己网站的特定Div (No iframe)中。例如:我在自己的网站上有一个这样的div:
<div id="weather-status"> Weather Status </div>
我也有这个网站:http://www.timeanddate.com/weather/和我想从这个网站(http://www.timeanddate.com/weather/)加载一个表格到我的div (天气状态),我该怎么做?
发布于 2011-11-17 08:21:41
<?php
$url = "http://www.timeanddate.com/weather/";
$page_all = file_get_contents($url);
preg_match('#<table class="border2 lpad wa">(.*)</table>#ms', $page_all, $div_array);
echo "<pre>";
print_r($div_array[0]);
echo "</pre>";
?>
使用以下CSS:
.wa {
margin: 0 auto;
}
.border2 {
background: none repeat scroll 0 0 #D7D6DC;
}
.lpad tr td {
padding: 0.2em;
}
https://stackoverflow.com/questions/8163412
复制相似问题