Hi Sir,

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.

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

<form name="search" method="post" action="st42.php">
<table width="736" border="0" cellpadding="0" cellspacing="0" summary="查詢">
  .......    
         <td class="search-in02">股票代碼:

            <input id="input_stock_code" name="input_stock_code" class="input01" size="6" maxlength="6">

            <A HREF="#" onclick="ChoiceStkCode(document.getElementById('input_stock_code'));" onkeypress="ChoiceStkCode(document.getElementById('input_stock_code'));" class="page_table-text_over">代碼查詢</A>                

            &nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="input01" value="查詢" onclick="query()" onkeypress="query()"/>      
  ........

</table>

</form>              
    function query(){               

        var code = document.getElementsByName("input_stock_code")[0].value;

        var param = 'ajax=true&input_stock_code='+code;

        setReport('result_st42.php',param );        

    }

---------------------------------------------------------------------------------

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

  1. Use curl_init to read in the site.
  2. Set textbox, "input_stock_code" with a value and simulate a button click.
  3. Parse the results from curl_exec().

Hi,

I wish I could read at least something on your linked website, then I can probably help you.

Anyways, I think curl will do it for you,.. you just have to look at the source of the form. Look for the name value of the submit button and then the form processor document.. allow your curl to follow external link wherever the form processing is located.

Here is a demo of a similar script that I wrote before. This script is running in three servers. There are two remotely located servers where the form query is submitted and script will wait for the servers response and then print those responses on the local server (third server).

So, I don't see any complexities on what you are trying to achieved..

Hi veedeoo,

Thanks for reply. Below is an English page of a similar site. I have checked your script, but it is different from my case. Actually this php page uses an invisible function, setReport() to modify $POST data to a series of number(I checked with Firebug andd Live Http) and sent it to its server. I have no idea the logic of this function. So I guess I still need to simulate actions in Step 2.

http://www.gretai.org.tw/en/stock/aftertrading/peratio_analysis/pera.php#

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.