Extract selection list from another site

Discussion in 'PHP' started by btfans, Dec 2, 2005.

  1. #1
    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/raceresult_all.asp?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/raceresult_all.asp?RaceDate="

    Thank You.

    
    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>
    
    Code (markup):
     
    btfans, Dec 2, 2005 IP
  2. btfans

    btfans Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Pls close it's resolved.
     
    btfans, Dec 5, 2005 IP