Jump to content

[SOLVED] Fetch information from other website


3s2ng

Recommended Posts

Hello Freaks,

 

Basis: http://www.onemotoring.com.sg/publish/onemotoring/en/on_the_roads/parking/parking_rates/downtown_rates.html

 

I just want to get the carpark rates from other website. Actually I've already manually copied some of the rates around 100's  and placed it in an excel sheet then my friend told me that theirs an easy way to copy those info using some PHP scripts. I've search the web but I cant find what is the term for that  ;D .Now I'm here hoping that somebody can help me.

 

Can anybody help me create this script? What are the things that I need to do.

 

Thanks,

MARK

<pre>
<?php
// Load page into string.
$page = file_get_contents('http://www.onemotoring.com.sg/publish/onemotoring/en/on_the_roads/parking/parking_rates/downtown_rates.html');
// Split the page by what we need.
$wanted_content = preg_split('/(?=Parking Rates in Car Parks Downtown)/', $page);
// What we need is the last part.
$wanted_content = array_pop($wanted_content);
// Match the content of 5 columns.
preg_match_all('%
	<td[^>]*>(.*?)</td>\s*
	<td[^>]*>(.*?)</td>\s*
	<td[^>]*>(.*?)</td>\s*
	<td[^>]*>(.*?)</td>\s*
	<td[^>]*>(.*?)</td>
%ix', $wanted_content, $matches, PREG_SET_ORDER);
// Toss the header row.
array_shift($matches);
// Toss the full matches.
foreach ($matches as &$match) {
	array_shift($match);
}
// Show results.
print_r($matches);
?>
</pre>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.