Ctrip api development solution

Source: Internet
Author: User
At the end of the Ctrip api development Post, lziyanl edited how to obtain content information from 2014-06-0313: 53: 29? I didn't find the corresponding interface on Ctrip and asked about the official group. I basically didn't take it seriously! ------ Solution -------------------- no CURL used ------ solution -------------------- If Ctrip api development in the source code

This post was last edited by lziyanl at 13:53:29 on



How to obtain the content information? I didn't find the corresponding interface on Ctrip and asked about the official group. I basically didn't take it seriously!
------ Solution --------------------
CURL used
------ Solution --------------------
If there is any content in the source code, you can capture it.
------ Solution --------------------
It is normal that the official group does not take proper measures. you collect others' things and increase the pressure on others' servers. Of course you won't be taken care.




$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('/(.*?)<\/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] => [limited quantity hot sale! Parent-Child Pass (Father's Day 6.14-15)] Tickets to Changlong Water Park in Guangzhou (5 special privileges for purchasing tickets !)
[Price] = & gt; 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] => Guangzhou Tower sightseeing tickets (currently paid for scenic spots)
[Price] = & gt; 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] => tickets to the impression Park Scenic Spot in Lingnan, Guangzhou (pay-as-you-go)
[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] => [hot sale !] Tickets to Guangdong Zhuhai Hengqin Changlong International Ocean Resort (Scenic spots)
[Price] = & gt; 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] => Aquarium tickets
[Price] = & gt; 120
)

[5] => Array
(
[Href] => http://vacations.ctrip.com/tickets/p1659651.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.