Page 1 of 1

[SOLVED] Extract selection list from another site

Posted: Fri Dec 02, 2005 4:32 am
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>

Posted: Fri Dec 02, 2005 9:31 am
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.

Posted: Mon Dec 05, 2005 8:17 pm
by btfans
Pls close it's resolved.