提供的API
https://rate.bot.com.tw/xrt?Lang=zh-TW 台灣銀行
https://www.esunbank.com.tw/bank/personal/deposit/rate/forex/foreign-exchange-rates 玉山銀行
檢查 網頁原始碼
<td data-table="本行即期賣出" class="rate-content-sight text-right print_hide" data-hide="phone">0.2817</td>
Select 的地方填入
.rate-content-cash.text-right.print_hide
,注意這邊的 Select 是 CSS 選擇器,就跟我們在寫 CSS 是一樣,例如我們要抓取的 class 在 HTML 呈現是 class=”rate-content-cash text-right print_hide”
,選擇器就變成 .rate-content-cash.text-right.print_hide
。https://www.esunbank.com.tw/bank/personal/deposit/rate/forex/foreign-exchange-rates
<td data-name="現金賣出匯率" class="even lastTd">0.2837</td>
Select 的地方填入
.evev.lattTd
[{"id":"6ea74d13.929d74","type":"debug","z":"acf5c35f.665d7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":790,"y":320,"wires":[]},{"id":"36bda223.9e1a7e","type":"comment","z":"acf5c35f.665d7","name":"Currency converter","info":"","x":130,"y":100,"wires":[]},{"id":"82a341fb.59f69","type":"inject","z":"acf5c35f.665d7","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":180,"wires":[["dccf7518.3a5178"]]},{"id":"d2678ccd.2002e","type":"debug","z":"acf5c35f.665d7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":180,"wires":[]},{"id":"dccf7518.3a5178","type":"http request","z":"acf5c35f.665d7","name":"Exchange","method":"GET","ret":"txt","url":"https://rate.bot.com.tw/xrt?Lang=zh-TW","tls":"","x":280,"y":180,"wires":[["7e9d89.07d0e278"]]},{"id":"fbbc192b.b0eda8","type":"comment","z":"acf5c35f.665d7","name":"https://rate.bot.com.tw/xrt?Lang=zh-TW","info":"","x":200,"y":140,"wires":[]},{"id":"497090d8.c1b0f","type":"http request","z":"acf5c35f.665d7","name":"Exchange","method":"GET","ret":"obj","url":"https://www.esunbank.com.tw/bank/personal/deposit/rate/forex/foreign-exchange-rates","tls":"","x":280,"y":320,"wires":[["82c39bc.5a6ef68"]]},{"id":"4bd25fa9.6468e","type":"inject","z":"acf5c35f.665d7","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":320,"wires":[["497090d8.c1b0f"]]},{"id":"dd51d6d5.9c7f48","type":"comment","z":"acf5c35f.665d7","name":"https://www.esunbank.com.tw/bank/personal/deposit/rate/forex/foreign-exchange-rates","info":"","x":350,"y":280,"wires":[]},{"id":"7e9d89.07d0e278","type":"html","z":"acf5c35f.665d7","name":"過濾 filter","property":"payload","outproperty":"payload","tag":".rate-content-cash.text-right.print_hide","ret":"text","as":"single","x":440,"y":180,"wires":[["d2678ccd.2002e","f52b4326.34eac"]]},{"id":"f52b4326.34eac","type":"function","z":"acf5c35f.665d7","name":"擷取 Capture","func":"var jp = msg.payload[15];\nvar date = new Date();\nvar h = date.getHours();\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n h = '0'+h;\n}\nif(m<10){\n m = '0' + m;\n}\nif(s<10){\n s = '0' + s;\n}\nmsg.payload = '(' + h + ':' + m + ':' + s + ')\\n'+\n'日幣匯率:' + jp ;\nreturn msg;\n","outputs":1,"noerr":0,"x":600,"y":220,"wires":[["d2678ccd.2002e"]]},{"id":"82c39bc.5a6ef68","type":"html","z":"acf5c35f.665d7","name":"過濾 filter","property":"payload","outproperty":"payload","tag":".even.lastTd","ret":"text","as":"single","x":440,"y":320,"wires":[["6ea74d13.929d74","fe715575.76af58"]]},{"id":"fe715575.76af58","type":"function","z":"acf5c35f.665d7","name":"擷取 Capture","func":"var jp = msg.payload[3];\nvar date = new Date();\nvar h = date.getHours();\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n h = '0'+h;\n}\nif(m<10){\n m = '0' + m;\n}\nif(s<10){\n s = '0' + s;\n}\nmsg.payload = '(' + h + ':' + m + ':' + s + ')\\n'+\n'日幣匯率:' + jp ;\nreturn msg;\n","outputs":1,"noerr":0,"x":620,"y":360,"wires":[["6ea74d13.929d74"]]}]
沒有留言:
張貼留言