Php: set textbox value, simulate a button click and read the data returned
<p>I am trying to collect some data from a php site. However this particular php page has transformed $POST data(to a special timestamp data that I can't replicate) with its own function(setReport() in below code) and sent to its server.
So in order to get this data, enter a stock number in the textbox and press the button is the only way to do I guess. </p>

<p>Below is the snippets from the source of php site that I want to grab data from.</p>

<h2><a href="http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php" rel="nofollow">http://www.gretai.org.tw/ch/stock/statistics/monthly/st42.php</a></h2>

<pre><code>&gt; &lt;form name="search" method="post" action="st42.php"&gt; &lt;table
&gt; width="736" border="0" cellpadding="0" cellspacing="0" summary="查詢"&gt;  
&gt; .......    
&gt;          &lt;td class="search-in02"&gt;股票代碼：
&gt; 
&gt;           &lt;input id="input_stock_code" name="input_stock_code"
&gt; class="input01" size="6" maxlength="6"&gt;
&gt; 
&gt;             &lt;A HREF="#" onclick="ChoiceStkCode(document.getElementById('input_stock_code'));"
&gt; onkeypress="ChoiceStkCode(document.getElementById('input_stock_code'));"
&gt; class="page_table-text_over"&gt;代碼查詢&lt;/A&gt;                
&gt; 
&gt;             &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="button" class="input01" value="查詢" onclick="query()" onkeypress="query()"/&gt;       
&gt; ........
&gt; 
&gt; &lt;/table&gt;
&gt; 
&gt; &lt;/form&gt;                   function query(){               
&gt; 
&gt;       var code = document.getElementsByName("input_stock_code")[0].value;
&gt; 
&gt;       var param = 'ajax=true&amp;input_stock_code='+code;
&gt; 
&gt;       setReport('result_st42.php',param );        
&gt; 
&gt;   }
</code></pre>

<hr>

<p>I am thinking of writing a PHP code with following steps to get the data. But I don't know how to do Step 2. Is there everyone who can help on this? Or there is another way to do it? Thanks so much!!!</p>

<ol>
<li>Use curl_init to read in the site.</li>
<li>Set textbox, "input_stock_code" with a value and simulate a button click.</li>
<li>Parse the results from curl_exec().</li>
</ol>
