Contents
Web上のtableタグのデータを取得し、二次元配列に格納します。
- 構文
- getTableData( table, Var arr )
- 引数
- table
- tableエレメント
- arr
- 取得したデータを格納する配列(参照引数)
- 戻値
プログラム
//////////////////////////////////////////////////
// 【引数】
// table : tableエレメント
// arr : 取得したデータを格納する配列(参照引数)
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE getTableData(table, Var arr[][])
rowMax = table.rows.length - 1
colMax = 0
FOR row = 0 TO table.rows.length - 1
IFB table.rows(row).cells.length - 1 > colMax THEN
colMax = table.rows(row).cells.length - 1
ENDIF
NEXT
DIM arr[rowMax][colMax]
FOR row = 0 TO table.rows.length - 1
FOR col = 0 TO table.rows(row).cells.length - 1
n = 0
WHILE arr[row][col + n] <> ""
n = n + 1
WEND
arr[row][col + n] = table.rows(row).cells(col).innerText
IFB table.rows(row).cells(col).rowSpan > 1 AND table.rows(row).cells(col).colSpan > 1 THEN
rmax = table.rows(row).cells(col).rowSpan - 1
cmax = table.rows(row).cells(col).colSpan - 1
FOR r = 1 TO rmax
FOR c = 1 TO cmax
arr[row + r][col + c] = "←"
NEXT
NEXT
ENDIF
IFB table.rows(row).cells(col).rowSpan > 1 THEN
n = table.rows(row).cells(col).rowSpan - 1
WHILE n
arr[row + n][col] = "↑"
n = n - 1
WEND
ENDIF
IFB table.rows(row).cells(col).colSpan > 1 THEN
n = table.rows(row).cells(col).colSpan - 1
WHILE n
arr[row][col + n] = "←"
n = n - 1
WEND
ENDIF
NEXT
NEXT
FEND
解説
- 2行目
- rowMaxに行数を代入する。
rowMax = table.rows.length - 1
- 3-8行目
- colMaxに列数を代入する。全部の行の最終列を調べ、最大列数を求める。
colMax = 0 FOR row = 0 TO table.rows.length - 1 IFB table.rows(row).cells.length - 1 > colMax THEN colMax = table.rows(row).cells.length - 1 ENDIF NEXT
- 9行目
- 取得したデータを格納するための二次元配列を生成。
DIM arr[rowMax][colMax]
- 10-11,40-41行目
- tableタグの行列だけループする。
FOR row = 0 TO table.rows.length - 1 FOR col = 0 TO table.rows(row).cells.length - 1 … NEXT NEXT
- 12-16行目
n = 0 WHILE arr[row][col + n] <> "" n = n + 1 WEND arr[row][col + n] = table.rows(row).cells(col).innerText
- 17-25行目
- rowSpan(行結合)とcolSpan(列結合)の両方があれば
IFB table.rows(row).cells(col).rowSpan > 1 AND table.rows(row).cells(col).colSpan > 1 THEN rmax = table.rows(row).cells(col).rowSpan - 1 cmax = table.rows(row).cells(col).colSpan - 1 FOR r = 1 TO rmax FOR c = 1 TO cmax arr[row + r][col + c] = "←" NEXT NEXT ENDIF
- 26-32行目
- rowSpan(行結合)があれば結合セルに「↑」を代入
IFB table.rows(row).cells(col).rowSpan > 1 THEN n = table.rows(row).cells(col).rowSpan - 1 WHILE n arr[row + n][col] = "↑" n = n - 1 WEND ENDIF
- 33-39行目
- colSpan(列結合)があれば結合セルに「←」を代入
IFB table.rows(row).cells(col).colSpan > 1 THEN n = table.rows(row).cells(col).colSpan - 1 WHILE n arr[row][col + n] = "←" n = n - 1 WEND ENDIF
プログラム実行例
お問い合わせ番号から佐川急便の配達状況を取得
DIM IE = IEBoot()
DIM no = "000000000000" // お問い合わせ番号
IE.Navigate("http://k2k.sagawa-exp.co.jp/p/web/okurijosearch.do?okurijoNo=" + no)
BusyWait(IE)
DIM element, elements
element = IE.document.getElementById("1")
elements = element.getElementsByTagName("table")
elements = elements.Item(3)
DIM array[-1][-1]
getTableData(elements, array)
FOR r = 0 TO UBound(array)
DIM str = ""
FOR c = 0 TO UBound(array[0])
str = str + array[r][c] + ","
NEXT
PRINT str
NEXT
//////////////////////////////////////////////////
// 【引数】
// IE : IEオブジェクト
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE BusyWait(Var IE)
SLEEP(0.500)
DIM t = GETTIME()
TRY
REPEAT
DIM tm = GETTIME() - t
FUKIDASI("BusyWait:" + tm)
SLEEP(0.010)
IF tm >= 60 THEN BREAK
UNTIL !IE.Busy AND IE.readyState = 4
EXCEPT
IE = getIEObj(-1)
PRINT IE.document.URL + " のIEオブジェクトを取得しました。"
BusyWait(IE)
ENDTRY
FUKIDASI()
FEND
//////////////////////////////////////////////////
// 【引数】
// 文字列 or 数値 : 取得したいIEオブジェクトのタイトル・URLもしくは数値を指定
// 完全一致フラグ : (TRUE : 文字列が完全一致したものを取得、FALSE : 文字列の一部を含むものを取得)
// 【戻値】
// Internet Explorerオブジェクト
//////////////////////////////////////////////////
FUNCTION getIEObj(str, flg = FALSE)
DIM Shell = CREATEOLEOBJ("Shell.Application")
SELECT CHKNUM(str)
CASE TRUE
DIM cnt = 0
SELECT TRUE
CASE str > 0
FOR n = 0 TO Shell.Windows.Count - 1
TRY
IFB Shell.Windows.Item(n).Name = "Internet Explorer" THEN
cnt = cnt + 1
IFB str = cnt THEN
RESULT = Shell.Windows.Item(n)
EXIT
ENDIF
ENDIF
EXCEPT
ENDTRY
NEXT
CASE str = 5
SELEND
RESULT = ERR_VALUE
FEND
//////////////////////////////////////////////////
// 【引数】
// table : tableエレメント
// arr : 取得したデータを格納する配列(参照引数)
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE getTableData(table, Var arr[][])
rowMax = table.rows.length - 1
colMax = 0
FOR row = 0 TO table.rows.length - 1
IFB table.rows(row).cells.length - 1 > colMax THEN
colMax = table.rows(row).cells.length - 1
ENDIF
NEXT
DIM arr[rowMax][colMax]
FOR row = 0 TO table.rows.length - 1
FOR col = 0 TO table.rows(row).cells.length - 1
n = 0
WHILE arr[row][col + n] ""
n = n + 1
WEND
arr[row][col + n] = table.rows(row).cells(col).innerText
IFB table.rows(row).cells(col).rowSpan > 1 AND table.rows(row).cells(col).colSpan > 1 THEN
rmax = table.rows(row).cells(col).rowSpan - 1
cmax = table.rows(row).cells(col).colSpan - 1
FOR r = 1 TO rmax
FOR c = 1 TO cmax
arr[row + r][col + c] = "←"
NEXT
NEXT
ENDIF
IFB table.rows(row).cells(col).rowSpan > 1 THEN
n = table.rows(row).cells(col).rowSpan - 1
WHILE n
arr[row + n][col] = "↑"
n = n - 1
WEND
ENDIF
IFB table.rows(row).cells(col).colSpan > 1 THEN
n = table.rows(row).cells(col).colSpan - 1
WHILE n
arr[row][col + n] = "←"
n = n - 1
WEND
ENDIF
NEXT
NEXT
FEND
//////////////////////////////////////////////////
// 【引数】
// InPrivate : InPrivateブラウズ・モードを有効にするときはTRUEを指定(デフォルトはFALSE)
// 【戻値】
// InternetExplorerオブジェクト
//////////////////////////////////////////////////
FUNCTION IEBoot(InPrivate = FALSE)
DIM IE
SELECT InPrivate
CASE TRUE
DOSCMD("start iexplore -private")
GETID("InPrivate - Internet Explorer - [InPrivate]", "IEFrame", -1)
IE = GETACTIVEOLEOBJ("InternetExplorer.Application","InPrivate - Internet Explorer - [InPrivate]")
CASE FALSE
TRY
IE = CREATEOLEOBJ("InternetExplorer.Application")
IE.Visible = TRUE
EXCEPT
EXEC("C:\Program Files\Internet Explorer\iexplore.exe")
GETID("Internet Explorer", "IEFrame", -1)
TRY
IE = GETACTIVEOLEOBJ("InternetExplorer.Application")
EXCEPT
IE = getIEObj(-1)
ENDTRY
ENDTRY
SELEND
RESULT = IE
FEND
//////////////////////////////////////////////////
// 【引数】
// 配列 : 上限値を求める配列
// 【戻値】
// 配列の上限値
//////////////////////////////////////////////////
FUNCTION UBound(array[])
RESULT = RESIZE(array)
FEND
- IEBoot
- IE.Navigate
- BusyWait
- getElementById
- Elements.getElementsByClassName
- Elements.Item
- getTableData
- UBound
- 結果
荷物状況,日時,担当営業所, ↓集荷 ,12/14 17:00 ,○○営業所 , ↓輸送中 ,12/14 17:02 ,○○中継センター , ↓輸送中 ,12/15 01:23 ,○○中継センター , ↓配達中 ,12/16 07:32 ,○○営業所 , ⇒ご不在 ,12/16 12:10 ,○○営業所 ,
気象庁のホームページから一月分の気温を取得しExcelでグラフを作成
CONST xlUp = -4162
CONST xlLineMarkers = 65
DIM year = 2020
DIM month = 8
DIM IE = IEBoot()
IE.Navigate("https://www.data.jma.go.jp/obd/stats/etrn/view/daily_s1.php?prec_no=14&block_no=47412&year=" + year + "&month=" + month + "&day=&view=p1")
BusyWait(IE)
DIM array[-1][-1]
DIM element = IE.document.getElementById("tablefix1")
getTableData(element, array)
IE.Quit
DIM Excel = XLOPEN()
DIM SheetName = Excel.ActiveSheet.Name
XLSETDATA(Excel, array, "A1")
DIM row = Excel.Cells(Excel.Rows.Count, 1).End(xlUp).Row
DIM Charts = Excel.Charts.Add
WITH Charts
.ChartType = xlLineMarkers
.SeriesCollection.NewSeries
.HasTitle = TRUE
.ChartTitle.Text = "札幌 " + year + "年" + month + "月気温"
WITH .FullSeriesCollection(1)
.XValues = "=Sheet1!$A$5:$A$35"
.Name = "=<#DBL>最高気温<#DBL>"
.Values = "=Sheet1!$H$5:$H$35"
WITH .Format
.Fill.ForeColor.RGB = 255
.Line.ForeColor.RGB = 255
ENDWITH
ENDWITH
WITH .FullSeriesCollection(2)
.XValues = "=Sheet1!$A$5:$A$35"
.Name = "=<#DBL>最高気温<#DBL>"
.Values = "=Sheet1!$I$5:$I$35"
WITH .Format
.Fill.ForeColor.RGB = 16711680
.Line.ForeColor.RGB = 16711680
ENDWITH
ENDWITH
ENDWITH
//////////////////////////////////////////////////
// 【引数】
// IE : IEオブジェクト
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE BusyWait(Var IE)
SLEEP(0.500)
DIM t = GETTIME()
TRY
REPEAT
DIM tm = GETTIME() - t
FUKIDASI("BusyWait:" + tm)
SLEEP(0.010)
IF tm >= 60 THEN BREAK
UNTIL !IE.Busy AND IE.readyState = 4
EXCEPT
IE = getIEObj(-1)
PRINT IE.document.URL + " のIEオブジェクトを取得しました。"
BusyWait(IE)
ENDTRY
FUKIDASI()
FEND
//////////////////////////////////////////////////
// 【引数】
// 文字列 or 数値 : 取得したいIEオブジェクトのタイトル・URLもしくは数値を指定
// 完全一致フラグ : (TRUE : 文字列が完全一致したものを取得、FALSE : 文字列の一部を含むものを取得)
// 【戻値】
// Internet Explorerオブジェクト
//////////////////////////////////////////////////
FUNCTION getIEObj(str, flg = FALSE)
DIM Shell = CREATEOLEOBJ("Shell.Application")
SELECT CHKNUM(str)
CASE TRUE
DIM cnt = 0
SELECT TRUE
CASE str > 0
FOR n = 0 TO Shell.Windows.Count - 1
TRY
IFB Shell.Windows.Item(n).Name = "Internet Explorer" THEN
cnt = cnt + 1
IFB str = cnt THEN
RESULT = Shell.Windows.Item(n)
EXIT
ENDIF
ENDIF
EXCEPT
ENDTRY
NEXT
CASE str = 5
SELEND
RESULT = ERR_VALUE
FEND
//////////////////////////////////////////////////
// 【引数】
// table : tableエレメント
// arr : 取得したデータを格納する配列(参照引数)
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE getTableData(table, Var arr[][])
rowMax = table.rows.length - 1
colMax = 0
FOR row = 0 TO table.rows.length - 1
IFB table.rows(row).cells.length - 1 > colMax THEN
colMax = table.rows(row).cells.length - 1
ENDIF
NEXT
DIM arr[rowMax][colMax]
FOR row = 0 TO table.rows.length - 1
FOR col = 0 TO table.rows(row).cells.length - 1
n = 0
WHILE arr[row][col + n] ""
n = n + 1
WEND
arr[row][col + n] = table.rows(row).cells(col).innerText
IFB table.rows(row).cells(col).rowSpan > 1 AND table.rows(row).cells(col).colSpan > 1 THEN
rmax = table.rows(row).cells(col).rowSpan - 1
cmax = table.rows(row).cells(col).colSpan - 1
FOR r = 1 TO rmax
FOR c = 1 TO cmax
arr[row + r][col + c] = "←"
NEXT
NEXT
ENDIF
IFB table.rows(row).cells(col).rowSpan > 1 THEN
n = table.rows(row).cells(col).rowSpan - 1
WHILE n
arr[row + n][col] = "↑"
n = n - 1
WEND
ENDIF
IFB table.rows(row).cells(col).colSpan > 1 THEN
n = table.rows(row).cells(col).colSpan - 1
WHILE n
arr[row][col + n] = "←"
n = n - 1
WEND
ENDIF
NEXT
NEXT
FEND
//////////////////////////////////////////////////
// 【引数】
// InPrivate : InPrivateブラウズ・モードを有効にするときはTRUEを指定(デフォルトはFALSE)
// 【戻値】
// InternetExplorerオブジェクト
//////////////////////////////////////////////////
FUNCTION IEBoot(InPrivate = FALSE)
DIM IE
SELECT InPrivate
CASE TRUE
DOSCMD("start iexplore -private")
GETID("InPrivate - Internet Explorer - [InPrivate]", "IEFrame", -1)
IE = GETACTIVEOLEOBJ("InternetExplorer.Application","InPrivate - Internet Explorer - [InPrivate]")
CASE FALSE
TRY
IE = CREATEOLEOBJ("InternetExplorer.Application")
IE.Visible = TRUE
EXCEPT
EXEC("C:\Program Files\Internet Explorer\iexplore.exe")
GETID("Internet Explorer", "IEFrame", -1)
TRY
IE = GETACTIVEOLEOBJ("InternetExplorer.Application")
EXCEPT
IE = getIEObj(-1)
ENDTRY
ENDTRY
SELEND
RESULT = IE
FEND
- IEBoot
- IE.Navigate
- BusyWait
- document.getElementById
- getTableData
- XLOPEN
- Excel.Application.ActiveSheet
- Excel.WorkSheet.Name
- XLSETDATA
- Excel.Application.Cells
- Excel.Range.End
- Excel.Range.Row
- Excel.Application.Charts
- Excel.Sheets.Add
- Excel.Charts
- Excel.Chart.ChartType
- Excel.Chart.SeriesCollection
- Excel.SeriesCollection.NewSeries
- Excel.Series
- Excel.Chart.HasTitle
- Excel.Chart.ChartTitle
- Excel.ChartTitle.Text
- Excel.Chart.FullSeriesCollection
- Excel.FullSeriesCollection
- Excel.FullSeriesCollection.Item
- Excel.Series.XValues
- Excel.Series.Name
- Excel.Series.Values
- Excel.Series.Format
- Excel.FillFormat.ForeColor
- Excel.ColorFormat.RGB
- Excel.LineFormat.FontColor
- 結果
楽天銀行定期預金の金利をExcelに保存
DIM IE = CREATEOLEOBJ("InternetExplorer.Application")
IE.Visible = TRUE
IE.Navigate("https://rbweb.rakuten-bank.co.jp/REF/main/fis/BasicTimeDepositInterestRate.html?PageID=BasicTimeDepositInterestRatePresentationLogicBean")
BusyWait(IE)
DIM elements = IE.document.getElementsByTagName("table")
DIM element = elements.Item(0)
DIM arr[-1][-1]
getTableData(element, arr)
IE.Quit
DIM Excel = XLOPEN()
XLSETDATA(Excel, arr, "A1")
DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject")
DIM path = uniqueFilename(FSO.BuildPath(GET_CUR_DIR, "楽天銀行定期預金金利.xlsx"))
XLCLOSE(Excel, path)
//////////////////////////////////////////////////
// 【引数】
// IE : IEオブジェクト
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE BusyWait(Var IE)
SLEEP(0.500)
DIM t = GETTIME()
TRY
REPEAT
DIM tm = GETTIME() - t
FUKIDASI("BusyWait:" + tm)
SLEEP(0.010)
IF tm >= 60 THEN BREAK
UNTIL !IE.Busy AND IE.readyState = 4
EXCEPT
IE = getIEObj(-1)
PRINT IE.document.URL + " のIEオブジェクトを取得しました。"
BusyWait(IE)
ENDTRY
FUKIDASI()
FEND
//////////////////////////////////////////////////
// 【引数】
// 文字列 or 数値 : 取得したいIEオブジェクトのタイトル・URLもしくは数値を指定
// 完全一致フラグ : (TRUE : 文字列が完全一致したものを取得、FALSE : 文字列の一部を含むものを取得)
// 【戻値】
// Internet Explorerオブジェクト
//////////////////////////////////////////////////
FUNCTION getIEObj(str, flg = FALSE)
DIM Shell = CREATEOLEOBJ("Shell.Application")
SELECT CHKNUM(str)
CASE TRUE
DIM cnt = 0
SELECT TRUE
CASE str > 0
FOR n = 0 TO Shell.Windows.Count - 1
TRY
IFB Shell.Windows.Item(n).Name = "Internet Explorer" THEN
cnt = cnt + 1
IFB str = cnt THEN
RESULT = Shell.Windows.Item(n)
EXIT
ENDIF
ENDIF
EXCEPT
ENDTRY
NEXT
CASE str = 5
SELEND
RESULT = ERR_VALUE
FEND
//////////////////////////////////////////////////
// 【引数】
// table : tableエレメント
// arr : 取得したデータを格納する配列(参照引数)
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE getTableData(table, Var arr[][])
rowMax = table.rows.length - 1
colMax = 0
FOR row = 0 TO table.rows.length - 1
IFB table.rows(row).cells.length - 1 > colMax THEN
colMax = table.rows(row).cells.length - 1
ENDIF
NEXT
DIM arr[rowMax][colMax]
FOR row = 0 TO table.rows.length - 1
FOR col = 0 TO table.rows(row).cells.length - 1
n = 0
WHILE arr[row][col + n] ""
n = n + 1
WEND
arr[row][col + n] = table.rows(row).cells(col).innerText
IFB table.rows(row).cells(col).rowSpan > 1 AND table.rows(row).cells(col).colSpan > 1 THEN
rmax = table.rows(row).cells(col).rowSpan - 1
cmax = table.rows(row).cells(col).colSpan - 1
FOR r = 1 TO rmax
FOR c = 1 TO cmax
arr[row + r][col + c] = "←"
NEXT
NEXT
ENDIF
IFB table.rows(row).cells(col).rowSpan > 1 THEN
n = table.rows(row).cells(col).rowSpan - 1
WHILE n
arr[row + n][col] = "↑"
n = n - 1
WEND
ENDIF
IFB table.rows(row).cells(col).colSpan > 1 THEN
n = table.rows(row).cells(col).colSpan - 1
WHILE n
arr[row][col + n] = "←"
n = n - 1
WEND
ENDIF
NEXT
NEXT
FEND
//////////////////////////////////////////////////
// 【引数】
// path : ファイルのパス
// 【戻値】
// 重複しないファイル名
//////////////////////////////////////////////////
FUNCTION uniqueFilename(path)
DIM FSO = CREATEOLEOBJ("Scripting.FileSystemObject")
IFB FSO.FileExists(path) THEN
DIM fol = FSO.GetParentFolderName(path)
DIM filename = FSO.GetBaseName(path)
DIM extension = FSO.GetExtensionName(path)
DIM i = 2
WHILE FSO.FileExists(FSO.BuildPath(fol, filename + " (" + i + ")." + extension))
i = i + 1
WEND
RESULT = FSO.BuildPath(fol, filename + " (" + i + ")." + extension)
ELSE
RESULT = path
ENDIF
FEND
- CREATEOLEOBJ
- IE.Visible
- IE.Navigate
- BusyWait
- IE.Document
- IE.document.getElementsByTagName
- getTableData
- XLOPEN
- XLSETDATA
- uniqueFilename
- FSO.BuildPath
- XLCLOSE
Yahoo!天気・災害情報より直近に発生した地震情報を取得しその場所をGoogleマップで表示
DIM IE = IEBoot()
IE.Navigate("http://typhoon.yahoo.co.jp/weather/earthquake/")
BusyWait(IE)
DIM ID = GETID("地震情報")
CTRLWIN(ID, MAX)
DIM array[-1][-1]
DIM element = IE.document.getElementById("eqinfdtl")
DIM elements = element.getElementsByTagName("table")
element = elements.Item(0)
getTableData(element, array)
HASHTBL tbl
FOR r = 0 TO UBound(array)
tbl[TRIM(array[r][0])] = array[r][1]
NEXT
DIM way[1]
IF POS("北緯", tbl["緯度/経度"]) THEN way[0] = "N"
IF POS("東経", tbl["緯度/経度"]) THEN way[1] = "E"
IF POS("西経", tbl["緯度/経度"]) THEN way[1] = "W"
IF POS("南緯", tbl["緯度/経度"]) THEN way[0] = "S"
tbl["緯度/経度"] = REPLACE(tbl["緯度/経度"], "度", "")
tbl["緯度/経度"] = REPLACE(tbl["緯度/経度"], "北緯", "")
tbl["緯度/経度"] = REPLACE(tbl["緯度/経度"], "東経", "")
tbl["緯度/経度"] = REPLACE(tbl["緯度/経度"], "西経", "-")
tbl["緯度/経度"] = REPLACE(tbl["緯度/経度"], "南緯", "-")
DIM coordinate = SPLIT(TRIM(tbl["緯度/経度"]), "/")
DIM z = 7
DIM url = "https://www.google.co.jp/maps/place/" + degToDMS(coordinate[0]) + way[0] + "," + degToDMS(coordinate[1]) + way[1] + "/@" + coordinate[0] + "," + coordinate[1] + "," + z + "z/"
url = REPLACE(url, "°", "%C2%B0")
url = REPLACE(url, "<#DBL>", "")
IE.Navigate(url)
BusyWait(IE)
//////////////////////////////////////////////////
// 【引数】
// IE : IEオブジェクト
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE BusyWait(Var IE)
SLEEP(0.500)
DIM t = GETTIME()
TRY
REPEAT
DIM tm = GETTIME() - t
FUKIDASI("BusyWait:" + tm)
SLEEP(0.010)
IF tm >= 60 THEN BREAK
UNTIL !IE.Busy AND IE.readyState = 4
EXCEPT
IE = getIEObj(-1)
PRINT IE.document.URL + " のIEオブジェクトを取得しました。"
BusyWait(IE)
ENDTRY
FUKIDASI()
FEND
//////////////////////////////////////////////////
// 【引数】
// deg : 角度(°)
// 【戻値】
// 角度(deg°分'秒")
//////////////////////////////////////////////////
FUNCTION degToDMS(deg)
DIM degree = INT(deg)
DIM minute = (deg - INT(deg)) * 60
DIM second = ROUND(minute - INT(minute), -10) * 60
RESULT = degree + "°" + INT(minute) + "'" + ROUND(second, -5) + ""
FEND
//////////////////////////////////////////////////
// 【引数】
// 文字列 or 数値 : 取得したいIEオブジェクトのタイトル・URLもしくは数値を指定
// 完全一致フラグ : (TRUE : 文字列が完全一致したものを取得、FALSE : 文字列の一部を含むものを取得)
// 【戻値】
// Internet Explorerオブジェクト
//////////////////////////////////////////////////
FUNCTION getIEObj(str, flg = FALSE)
DIM Shell = CREATEOLEOBJ("Shell.Application")
SELECT CHKNUM(str)
CASE TRUE
DIM cnt = 0
SELECT TRUE
CASE str > 0
FOR n = 0 TO Shell.Windows.Count - 1
TRY
IFB Shell.Windows.Item(n).Name = "Internet Explorer" THEN
cnt = cnt + 1
IFB str = cnt THEN
RESULT = Shell.Windows.Item(n)
EXIT
ENDIF
ENDIF
EXCEPT
ENDTRY
NEXT
CASE str = 5
SELEND
RESULT = ERR_VALUE
FEND
//////////////////////////////////////////////////
// 【引数】
// table : tableエレメント
// arr : 取得したデータを格納する配列(参照引数)
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE getTableData(table, Var arr[][])
rowMax = table.rows.length - 1
colMax = 0
FOR row = 0 TO table.rows.length - 1
IFB table.rows(row).cells.length - 1 > colMax THEN
colMax = table.rows(row).cells.length - 1
ENDIF
NEXT
DIM arr[rowMax][colMax]
FOR row = 0 TO table.rows.length - 1
FOR col = 0 TO table.rows(row).cells.length - 1
n = 0
WHILE arr[row][col + n] ""
n = n + 1
WEND
arr[row][col + n] = table.rows(row).cells(col).innerText
IFB table.rows(row).cells(col).rowSpan > 1 AND table.rows(row).cells(col).colSpan > 1 THEN
rmax = table.rows(row).cells(col).rowSpan - 1
cmax = table.rows(row).cells(col).colSpan - 1
FOR r = 1 TO rmax
FOR c = 1 TO cmax
arr[row + r][col + c] = "←"
NEXT
NEXT
ENDIF
IFB table.rows(row).cells(col).rowSpan > 1 THEN
n = table.rows(row).cells(col).rowSpan - 1
WHILE n
arr[row + n][col] = "↑"
n = n - 1
WEND
ENDIF
IFB table.rows(row).cells(col).colSpan > 1 THEN
n = table.rows(row).cells(col).colSpan - 1
WHILE n
arr[row][col + n] = "←"
n = n - 1
WEND
ENDIF
NEXT
NEXT
FEND
//////////////////////////////////////////////////
// 【引数】
// InPrivate : InPrivateブラウズ・モードを有効にするときはTRUEを指定(デフォルトはFALSE)
// 【戻値】
// InternetExplorerオブジェクト
//////////////////////////////////////////////////
FUNCTION IEBoot(InPrivate = FALSE)
DIM IE
SELECT InPrivate
CASE TRUE
DOSCMD("start iexplore -private")
GETID("InPrivate - Internet Explorer - [InPrivate]", "IEFrame", -1)
IE = GETACTIVEOLEOBJ("InternetExplorer.Application","InPrivate - Internet Explorer - [InPrivate]")
CASE FALSE
TRY
IE = CREATEOLEOBJ("InternetExplorer.Application")
IE.Visible = TRUE
EXCEPT
EXEC("C:\Program Files\Internet Explorer\iexplore.exe")
GETID("Internet Explorer", "IEFrame", -1)
TRY
IE = GETACTIVEOLEOBJ("InternetExplorer.Application")
EXCEPT
IE = getIEObj(-1)
ENDTRY
ENDTRY
SELEND
RESULT = IE
FEND
//////////////////////////////////////////////////
// 【引数】
// 配列 : 上限値を求める配列
// 【戻値】
// 配列の上限値
//////////////////////////////////////////////////
FUNCTION UBound(array[])
RESULT = RESIZE(array)
FEND
- IEBoot
- IE.Navigate
- BusyWait
- GETID
- CTRLWIN
- document.getElementById
- Element.getElementsByTagName
- Elements.Item
- getTableData
- UBound
- TRIM
- POS
- REPLACE
- SPLIT
- degToDMS
関連記事
- BusyWait
- 引数に指定したInternetExplorerオブジェクトの読み込みが完了するのを待ちます。
- getIEObj
- 引数に指定した「タイトル」または「URL」を含むInternetExplorerオブジェクトを返します。数値nを指定した場合、n番目に開いたInternetExplorerオブジェクトを取得します。負の数で後ろからn番目。IELINK関数で開かれた新しいタブのInternetExplorerオブジェクトを取得したいときに使います。
- IENoticeBar
- Web上でファイルをダウンロードしたときに出る通知バーの制御を行います。ダウンロードしたファイル名を返します。
- altClick
- Web上(IE)の指定したalt属性を含む画像をクリックします。クリックに成功した場合はTrue、失敗した場合はFalseを返します。
- IEBoot
- InternetExplorerオブジェクトを生成します。iexplorer.exeのプロセスが残っているときにCREATEOLEOBJ関数でInternet Explorerを起動するとエラーが出ることがあるので、それを回避するための関数です。
- DownloadFile
- 指定したURLのファイルをダウンロードします。第一引数にダウンロードするファイルのURL、第二引数にダウンロード先のフォルダ名、第三引数にダウンロードするファイル名を指定します。ダウンロードに成功した場合はTrue、失敗した場合はFalseを返します。