COCO研究院

 找回密碼
 註冊
搜索
查看: 3463|回復: 9

[其他程式語言] 請問期交所網頁查詢每日行情

[複製鏈接]
發表於 12-8-22 12:53 | 顯示全部樓層 |閱讀模式
100金錢
想寫一個程式自動上期交所網站查詢每日行情表,
http://www.taifex.com.tw/chinese/3/3_1_1.asp
雖然有看到下面這個Link
http://www.taifex.com.tw/chinese/3/3_1_1_tbl.asp
但是無法修改日期,想請教coco高手正確的Link的格式?

最佳答案

查看完整內容

http://www.taifex.com.tw/chinese/3/3_1_1_tbl.asp?syear=2012&smonth=08&sday=17
發表於 12-8-22 12:53 | 顯示全部樓層
回復

使用道具 舉報

發表於 12-8-22 13:10 | 顯示全部樓層
本帖最後由 cococharles 於 12-8-22 13:12 編輯

格式:
http://www.taifex.com.tw/chinese/3/3_1_1_tbl.asp?syear=<year>&smonth=<month>&sday=<day>&commodity_id=<id>
<year> = 2011,2012....
<month> = 01,02,....
<day> = 01,02,....
<id> = TX,MTX,....
例如:
"http://www.taifex.com.tw/chinese/3/3_1_1_tbl.asp?syear=2011&smonth=08&sday=16&commodity_id=MTX"


回復

使用道具 舉報

發表於 12-8-22 13:15 | 顯示全部樓層
破解這一段 html 即可得到答案:

<input type="hidden" name="qtype" id="qtype" value="">
<input type="hidden" name="commodity_id" id="commodity_id" value="TX">
<input type="hidden" name="commodity_id2" id="commodity_id2" value="">
<input type="hidden" name="commodity_name" id="commodity_name" value="臺股期貨 (TX)">
<input type="hidden" name="goday" value="">
<input type="hidden" name="dateaddcnt" value="0">  
<input type="hidden" name="DATA_DATE_Y" value="2012">  
<input type="hidden" name="DATA_DATE_M" value="08">  
<input type="hidden" name="DATA_DATE_D" value="20">      
<input type="hidden" name="syear" id="syear" value="2012">
<input type="hidden" name="smonth" id="smonth" value="08">
<input type="hidden" name="sday" id="sday" value="20">

評分

參與人數 2金錢 +7 收起 理由
comewish + 5 很感謝你,我看了半天看不太懂,原來是這樣.
joey0415 + 2 太強了!

查看全部評分

回復

使用道具 舉報

發表於 12-8-22 13:17 | 顯示全部樓層
謝謝 c大的 100塊現大洋!
回復

使用道具 舉報

發表於 12-8-22 13:19 | 顯示全部樓層
哇!原來是這樣看的..恩筆記筆記..我們那個年代 WWW不發達
對於網頁的東西..實在是不知道該如何入手學會這些阿..
回復

使用道具 舉報

發表於 12-8-22 14:58 | 顯示全部樓層
shex 發表於 12-8-22 13:19
哇!原來是這樣看的..恩筆記筆記..我們那個年代 WWW不發達
對於網頁的東西..實在是不知道該如何入手學會這 ...

現在網路發達
先想好自己要啥?再上網搜尋相關資料和基本例子
然後動手自己踹
這樣的學習效果最佳
回復

使用道具 舉報

發表於 12-8-22 16:15 | 顯示全部樓層
本帖最後由 cococharles 於 12-8-22 17:21 編輯
shex 發表於 12-8-22 13:19
哇!原來是這樣看的..恩筆記筆記..我們那個年代 WWW不發達
對於網頁的東西..實在是不知道該如何入手學會這 ...

s大如果有興趣, 可以先瞭解 HTML 語法, 從 google 搜尋就可找到許多網站, 例如:     http://www.pt.ntu.edu.tw/hmchai/ptcomputer03_2/hHTML/HTMLintroduction.htm
http://www.pt.ntu.edu.tw/hmchai/ptcomputer03_2/hHTML/HTMLform.htm
然後需要一點 JavaScript 的知識.
以這題下載期交所資料為例, 我破解的步驟如下:
(1) 從瀏覽器看網頁原始碼:   http://www.taifex.com.tw/chinese/3/3_1_1.asp
(2) 按鍵名稱 "送出查詢", 所以就在原始檔搜尋 "送出查詢" 這個字串.
(3) 在 html 中的查詢都是被 "form" 這個架構包起來的, 我們會發現所屬的 form 為 "<form name="myform" method="post">"
      因為沒有 "action" 參數, 所以按鍵後資料會回饋到自己 "3_1_1.asp"
(4) 接著檢查 form 裡面的資訊:
    <input type="hidden" name="commodity_id" id="commodity_id" value="TX">
   ....   
    <input type="hidden" name="syear" id="syear" value="2012">
    <input type="hidden" name="smonth" id="smonth" value="8">
    <input type="hidden" name="sday" id="sday" value="22">
     這些 commodity_id, syear....將被當作參數餵給 "3_1_1.asp"
(5) 將這些資訊串接起來, 並經過一些 test, 得到格式如下:
     http://www.taifex.com.tw/chinese/3/3_1_1_tbl.asp?syear=<year>&smonth=<month>&sday=<day>&commodity_id=<id>

給 s大做參考, 如有問題可與小弟聯繫。



評分

參與人數 2金錢 +4 收起 理由
joey0415 + 2 太強了!三大法人的網頁有限制!.
shex + 2 感謝

查看全部評分

回復

使用道具 舉報

發表於 12-9-11 20:05 | 顯示全部樓層
前幾天還在看網頁原始碼試格式而傷腦筋,讀完這篇後猶如大夢初醒實在獲益良多,非常謝謝cococharles 的分享。
回復

使用道具 舉報

發表於 12-10-1 15:30 | 顯示全部樓層
很實用, 謝謝分享 !!
回復

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-5-4 11:51

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook