Re: [問題] 在個人網頁中,做到輸入代碼,而抓取網 …

看板Web_Design作者 (藍藍紫黃橘 粉灰白綠咖)時間15年前 (2011/01/06 21:52), 編輯推噓3(303)
留言6則, 4人參與, 最新討論串1/1
※ 引述《yukiis (yukiis)》之銘言: : 請問如何在個人網頁或部落格中(ex.痞客邦) : 做到類似yahoo股市的效果: : http://tw.stock.yahoo.com/d/s/credit_2330.html : 就是建立一個輸入框,一個送出鈕, : 輸入代碼2330後,按下按鈕, : 能在同一網頁(另開新頁亦可)下方抓到並秀出該網路上的圖片 : 圖片的來源來自網路上,不需個人的資料庫或伺服器, : 圖片的網址具有一定的規則,例如: : http://tw.stock.yahoo.com/i/d/creditfn_2330.png
: http://tw.stock.yahoo.com/i/d/creditso_2330.png
: 只要改變"2330",就會變成是另一張圖,(例如改成"2317") : 只要能單純做到上述效果就好 : 希望能提供完整html語法,需使用到javascript亦可! : (對網頁設計認識很有限,希望能直接貼上…) : 謝謝大大的回答!! Demo: https://sites.google.com/site/tominxd/stock.html Code: <form name="stock" method="post"> 股票代號:<input type="input" name="input" id="input"> <input type="submit" name="submit"> </form> <div id="content_main"></div> <script type="text/javascript" src="" rel="nofollow">http://www.google.com/jsapi"></script> <script type="text/javascript">google.load("jquery","1")</script> <script type="text/javascript"> $("form").submit(function(){ getImg(); return false; }); $("#input").focus(); function getImg(){ var id = $("input").val(); var html = "<img src=http://tw.stock.yahoo.com/i/d/creditfn_"+ id + ".png /><br /><br /><img src=http://tw.stock.yahoo.com/i/d/creditso_"+ id + ".png />" ; $("#content_main").html(html); } </script> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.122.30.198

01/06 21:55, , 1F
你是個好人
01/06 21:55, 1F

01/06 23:14, , 2F
太感謝了!(淚),沒想到這麼快就有熱心的大大回應~
01/06 23:14, 2F

01/06 23:16, , 3F
不知用什麼方式答謝… 在下是在證券行業,所以碰到如上需求
01/06 23:16, 3F

01/06 23:17, , 4F
如果大大有金融相關的興趣,歡迎來信或站上討論,再次感謝!
01/06 23:17, 4F

01/07 00:14, , 5F
不客氣:D
01/07 00:14, 5F

01/07 13:27, , 6F
原來jQuery就可以辦到了阿~
01/07 13:27, 6F
文章代碼(AID): #1D9SaTLi (Web_Design)