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

Link to comment
Share on other sites

<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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.