找回密码
 加入
搜索
查看: 830|回复: 7

[网络通信] IE 抓取銀行匯率 問題 如何將網頁資料變成數組[已解決]

[复制链接]
发表于 2022-1-19 00:58:07 | 显示全部楼层 |阅读模式
本帖最后由 kk_lee69 于 2022-2-11 20:24 编辑

網址如下:
https://www.bankchb.com/frontend/G0100_query.jsp

如何將上面的銀行匯率 變成數組....

實在搞不懂網頁的操作.....
发表于 2022-1-19 08:17:10 | 显示全部楼层
本帖最后由 floor6ggg 于 2022-1-19 08:20 编辑
#include <Array.au3>
#include <IE.au3>
$oIE = _IEAttach("https://www.bankchb.com/frontend/G0100_query.jsp","url")
Local $oTable = _IETableGetCollection($oIE, 0)
$aTableData = _IETableWriteToArray($oTable, True)
_ArrayDisplay($aTableData,'Debug~~~')
发表于 2022-1-19 12:10:06 | 显示全部楼层
页面接口,直接返回json数据,不用解析页面
https://www.bankchb.com/frontend/jsp/getG0100_query.jsp
 楼主| 发表于 2022-1-20 00:55:35 | 显示全部楼层
chamlien 发表于 2022-1-19 12:10
页面接口,直接返回json数据,不用解析页面
https://www.bankchb.com/frontend/jsp/getG0100_query.jsp

高手 你這段網址怎麼抓出來的....?? 如何應用 JSON
 楼主| 发表于 2022-1-21 23:17:01 | 显示全部楼层

這個方法過不了 抓不到資料ㄟ
发表于 2022-1-23 12:43:15 | 显示全部楼层
写个例子给你
#include <array.au3>
$url = "https://www.bankchb.com/frontend/jsp/getG0100_query.jsp"
$xmlhttp = ObjCreate("msxml2.xmlhttp")
With $xmlhttp
        .open("GET", $url, False)
        .send
        If .status = 200 Then
                $str = .responsetext
        EndIf
EndWith
If $str <> "" Then
        Dim $arr[3] = ["curname", "buy", "sell"]
        $hf = ObjCreate("htmlfile")
        $hf.write("<script></script>")
        With $hf.parentwindow
                .eval("var json=" & $str)
                $n = .eval("json.datas.length")
                If $n > 0 Then
                        Dim $result[$n][3]
                        For $i = 0 To $n - 1
                                For $t = 0 To UBound($arr) - 1
                                        $result[$i][$t] = .eval("json.datas[" & $i & "]." & $arr[$t])
                                Next
                        Next
                        _ArrayDisplay($result,Default,Default,Default,Default,"curname|buy|sell")
                EndIf
        EndWith
EndIf
发表于 2022-2-8 22:30:59 | 显示全部楼层
学习啊,学习下~
 楼主| 发表于 2022-2-11 20:24:11 | 显示全部楼层

感謝幫忙  我們公司最近 換 ERP 系統.... 所以...忙到沒時間上線.....不好意思

也就是 換 ERP 系統~~  所以 有這個匯率轉換 需求 增加了~~~

感謝 幫忙  ~~  
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-26 15:14 , Processed in 0.074656 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表