[SOLVED] Extract selection list from another site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
btfans
Forum Newbie
Posts: 22
Joined: Thu Jun 10, 2004 10:58 am

[SOLVED] Extract selection list from another site

Post by btfans »

Extract selection list from another site

Hi,

This should be a coding to use preg_match or preg_match_all, but pls
point me the correct way...to do this ?

I want to extract the selection date list from another site, and then
put to my own as to be selected in horse.php (code as bottom),
when a date selected, the date is parsed as $indate to be append
at end to the link ("http://www.hkjc.com/chinese/racing/race ... ?RaceDate=")
for a new enquiry. The horse.php now only try to find the latest date.
But this list is dynamic.. something as follow if view the source:

<select name="raceDate">
<option value='30/11/2005'>30/11/2005</option>
<option value='27/11/2005'>27/11/2005</option>
<option value='23/11/2005'>23/11/2005</option>
:
:
</select>

From "http://www.hkjc.com/chinese/racing/race ... ?RaceDate="

Thank You.

Code: Select all

horse.php
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>Horse Result</title>
</head>
<body>
Horse Result -
<hr><br>

<?

	$file = "http://www.hkjc.com/chinese/racing/Results.asp";
	$contents = file($file);
	$size = sizeof($contents);
    	$alldata=implode("\n", $contents);
    	preg_match_all("|<form.*?>(.*?)</form>|ism",$alldata,$matches); 
    	foreach($matches[1] as $match) 
	{    	$pieces = explode("\n", $match);



		$indate = substr($pieces[10], 19);

	}

	$file = "http://www.hkjc.com/chinese/racing/raceresult_all.asp?RaceDate=" . $indate;
	$contents = file($file);
	$size = sizeof($contents);
	for($i = 0; $i < $size; $i++) {
	
	$alldata = $contents[$i];
	echo $alldata; }

?>
</body>
</html>
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

stealing content is bad, mmmmk.

Will work on something and get back later (possibly)

But first would like to suggest it is better, and also not down right cheeky, to generate your own dynamic function to complete this task, than to just ripoff someone elses work.
btfans
Forum Newbie
Posts: 22
Joined: Thu Jun 10, 2004 10:58 am

Post by btfans »

Pls close it's resolved.
Post Reply