【发布时间】:2014-04-29 06:22:30
【问题描述】:
我在这里尝试从网页中获取地址和电话号码。这是没有给出任何错误但也没有给出任何结果的代码。
有什么问题吗?
我正在尝试从页面中获取address、image 和phone。
代码如下:
include_once('simple_html_dom.php');
function getData($url)
{
print("$url\n");
$root = new stdClass();
$items = array();
$html = file_get_html($url);
if($html) {
$containers = $html->find('div.mapbox div.mapbox-text strong.street-address address.address');
foreach($containers as $container) {
$comments = $container->find('address.address span');
$item = new stdClass();
foreach($comments as $comment) {
$address.= $comment->itemprop; //append the content of each span
}
echo $address;
$getphone = $container->find('span.biz-phone');
$phone = $getphone->itempro;
}
$Imgcontainers = $html->find('div.js-photo photo photo-1 div.showcase-photo-box img.a la beverly sills');
echo $Imgcontainers->img;
}
}
$url = 'http://www.yelp.com/biz/locanda-san-francisco?start='.$i.'';
$root = getData($url);
【问题讨论】: