携程api开发 本帖最后由 lziyanl 于 2014-06-03 13:53:29 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 官方群不搭理是正常的,你采集别人的东西,对别人服务器增加压力。当然不会搭理你。<?php$content = file_get_contents('http://www.ctrip.com/');$pos1 = strpos($content, '<div class="vac_item vac_item_main">');$pos2 = strpos($content, '<div id="guessvacation_list" class="h2tab_cn" style="display:none;"></div>');$content = substr($content, $pos1, $pos2-$pos1);// hrefpreg_match_all('/<a.*?href="((http(s)?:\/\/).*?)".*?/si', $content, $matches);$href = array_values(array_unique($matches[1]));// srcpreg_match_all('/_src=\"(.*?)\"/i', $content, $matches);$src = $matches[1];// titlepreg_match_all('/title=\"(.*?)\"/i', $content, $matches);$title = $matches[1];// pricepreg_match_all('/<span class=\"c_price\">(.*?)<\/span>/i', $content, $matches);$price = $matches[1];$data = array();for($i=0,$len=count($href); $i<$len; $i++){ $data[] = array( 'href' => $href[$i], 'src' => $src[$i], 'title' => $title[$i], 'price' => $price[$i], );}print_r($data);?>Array( [0] => Array ( [href] => http://vacations.ctrip.com/tickets/p1833645.html [src] => http://pkgpic.ctrip.com/images2/1/152/152_3391_g07660.jpg [title] => 【限量热卖!亲子套票(父亲节6.14-15)】广州长隆水上乐园门票(购票享5大特权!) [price] => 285 ) [1] => Array ( [href] => http://vacations.ctrip.com/tickets/p1655820.html [src] => http://pkgpic.ctrip.com/images2/1/152/152_1660_g07660-m.jpg [title] => 广州塔观光门票(景区现付) [price] => 135 ) [2] => Array ( [href] => http://vacations.ctrip.com/tickets/p83829.html [src] => http://pkgpic.ctrip.com/images2/1/152/152_3331_g07660-m.jpg [title] => 广州岭南印象园景区门票(景区现付) [price] => 30 ) [3] => Array ( [href] => http://vacations.ctrip.com/tickets/p1811853.html [src] => http://pkgpic.ctrip.com/images2/1/27/27_523_g07660-m.jpg [title] => 【热卖!】广东珠海横琴长隆国际海洋度假区门票(各景区) [price] => 100 ) [4] => Array ( [href] => http://vacations.ctrip.com/tickets/p84788.html [src] => http://pkgpic.ctrip.com/images2/1/152/152_919_s28632-m.jpg [title] => 广州海洋馆门票 [price] => 120 ) [5] => Array ( [href] => http://vacations.ctrip.com/tickets/p1659651.html [src] => http://pkgpic.ctrip.com/images2/1/27/27_134_s31517-m.jpg [title] => 【独家!特权日半价热卖(6.28-29日)】珠海海泉湾海洋温泉门票(景区现付) [price] => 90 ) [6] => Array ( [href] => http://vacations.ctrip.com/tickets/p84522.html [src] => http://pkgpic.ctrip.com/images2/1/207/207_697_s45214-m.jpg [title] => 广东顺德长鹿农庄门票 [price] => 35 )) 求推荐个PHP+MySQL的体育运动方面的俱乐部的源码 有关dedecms的标签问题 新手请教高手问题。 php集成环境安装好了,但运行不起来,请高手帮忙,急急.... 请教高手 PHP 和 DELPHI 开发一个功能 可以实现吗? 3G和JAVA 有哪些优势? php服务器不显示html if(date("His",$now) >= 235800)看看这么会由问题吗? ecshop手机访问自己添加的页面会自动跳转到/mobile目录下 新人报到 window+nginx+php-cgi,怎么配置php解析非阻塞队列式解析php? 有懂drupal的大神吗
<?php
$content = file_get_contents('http://www.ctrip.com/');
$pos1 = strpos($content, '<div class="vac_item vac_item_main">');
$pos2 = strpos($content, '<div id="guessvacation_list" class="h2tab_cn" style="display:none;"></div>');
$content = substr($content, $pos1, $pos2-$pos1);// href
preg_match_all('/<a.*?href="((http(s)?:\/\/).*?)".*?/si', $content, $matches);
$href = array_values(array_unique($matches[1]));// src
preg_match_all('/_src=\"(.*?)\"/i', $content, $matches);
$src = $matches[1];// title
preg_match_all('/title=\"(.*?)\"/i', $content, $matches);
$title = $matches[1];// price
preg_match_all('/<span class=\"c_price\">(.*?)<\/span>/i', $content, $matches);
$price = $matches[1];$data = array();for($i=0,$len=count($href); $i<$len; $i++){
$data[] = array(
'href' => $href[$i],
'src' => $src[$i],
'title' => $title[$i],
'price' => $price[$i],
);
}print_r($data);
?>
Array
(
[0] => Array
(
[href] => http://vacations.ctrip.com/tickets/p1833645.html
[src] => http://pkgpic.ctrip.com/images2/1/152/152_3391_g07660.jpg
[title] => 【限量热卖!亲子套票(父亲节6.14-15)】广州长隆水上乐园门票(购票享5大特权!)
[price] => 285
) [1] => Array
(
[href] => http://vacations.ctrip.com/tickets/p1655820.html
[src] => http://pkgpic.ctrip.com/images2/1/152/152_1660_g07660-m.jpg
[title] => 广州塔观光门票(景区现付)
[price] => 135
) [2] => Array
(
[href] => http://vacations.ctrip.com/tickets/p83829.html
[src] => http://pkgpic.ctrip.com/images2/1/152/152_3331_g07660-m.jpg
[title] => 广州岭南印象园景区门票(景区现付)
[price] => 30
) [3] => Array
(
[href] => http://vacations.ctrip.com/tickets/p1811853.html
[src] => http://pkgpic.ctrip.com/images2/1/27/27_523_g07660-m.jpg
[title] => 【热卖!】广东珠海横琴长隆国际海洋度假区门票(各景区)
[price] => 100
) [4] => Array
(
[href] => http://vacations.ctrip.com/tickets/p84788.html
[src] => http://pkgpic.ctrip.com/images2/1/152/152_919_s28632-m.jpg
[title] => 广州海洋馆门票
[price] => 120
) [5] => Array
(
[href] => http://vacations.ctrip.com/tickets/p1659651.html
[src] => http://pkgpic.ctrip.com/images2/1/27/27_134_s31517-m.jpg
[title] => 【独家!特权日半价热卖(6.28-29日)】珠海海泉湾海洋温泉门票(景区现付)
[price] => 90
) [6] => Array
(
[href] => http://vacations.ctrip.com/tickets/p84522.html
[src] => http://pkgpic.ctrip.com/images2/1/207/207_697_s45214-m.jpg
[title] => 广东顺德长鹿农庄门票
[price] => 35
))