php携程 线程,携程api开发解决方法

携程api开发

本帖最后由 lziyanl 于 2014-06-03 13:53:29 编辑

19411188.jpg

如何获取上图的内容信息?在携程没找到对应接口,询问官方群,基本不搭理!

------解决方案--------------------

CURL用过没

------解决方案--------------------

源码里如果有内容的话应该是可以抓取吧

------解决方案--------------------

官方群不搭理是正常的,你采集别人的东西,对别人服务器增加压力。当然不会搭理你。

19411189.jpg

$content = file_get_contents('http://www.ctrip.com/');

$pos1 = strpos($content, '

');

$pos2 = strpos($content, '

$content = substr($content, $pos1, $pos2-$pos1);

// href

preg_match_all('/

$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('/(.*?)/i', $content, $matches);

$price = $matches[1];

$data = array();

for($i=0,$len=count($href); $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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值