ページにアクセスすると、そのページ内の情報(IE.document)が取得できます
■ドキュメント
- タイトル
- IE.document.title
- ドキュメントタイプ
- IE.document.doctype
■ベース色
- 背景色
- IE.document.bgColor
- 文字色
- IE.document.fgColor
■文字コード
- 文字コード
- IE.document.charSet
- ブラウザのデフォルト文字コード
- IE.document.defaultCharset
■リンク文字色
- リンク中の文字色
- IE.document.alinkColor
- リンク文字色
- IE.document.linkColor
- リンク済の文字色
- IE.document.vlinkColor
■アンカーオブジェクト
- アンカーの数
- IE.document.anchors.length
- アンカー名(0からの数字を指定)
- IE.document.anchors[n].name
■クッキー
- クッキー
- IE.document.cookie
■ドメイン
- ドメイン名
- IE.document.domain
- 現在のページのURL
- IE.document.URL
- 指定座標上のオブジェクト情報
- IE.document.elementFromPoint(X,Y)
■リファラ
- リファラ
- IE.document.referrer
というわけで、ひとつひとつ解説するよりは
具体的にスクリプトを実行させて、結果を見てみましょう。
IE = CREATEOLEOBJ( "InternetExplorer.Application" ) |
IE.navigate( "http://canal22.org/sample0001" ) |
UNTIL !IE.busy AND IE.readyState = 4 |
PRINT " IE.document.title=" + IE.document.title |
PRINT " IE.document.doctype=" + IE.document.doctype |
PRINT " IE.document.bgColor=" + IE.document.bgColor |
PRINT " IE.document.fgColor=" + IE.document.fgColor |
PRINT " IE.document.charSet=" + IE.document.charSet |
PRINT " IE.document.defaultCharset=" + IE.document.defaultCharset |
PRINT " IE.document.alinkColor=" + IE.document.alinkColor |
PRINT " IE.document.linkColor=" + IE.document.linkColor |
PRINT " IE.document.vlinkColor=" + IE.document.linkColor |
PRINT " IE.document.anchors.length=" + IE.document.anchors.length |
FOR A = 0 TO (IE.document.anchors.length - 1) |
PRINT " アンカー名(" + A + ")" |
PRINT " IE.document.anchors[" + A + "].name=" + IE.document.anchors[A].name |
PRINT " IE.document.cookie=" + IE.document.cookie |
PRINT " IE.document.domain=" + IE.document.domain |
PRINT " IE.document.URL=" + IE.document.URL |
PRINT " 指定座標上のオブジェクト情報(ここではx=100,y=100を指定)" |
PRINT " IE.document.elementFromPoint(100,100)=" + IE.document.elementFromPoint(100,100) |
IE.document.links[0].click() |
UNTIL !IE.busy AND IE.readyState = 4 |
PRINT " IE.document.referrer=" + IE.document.referrer |
IE.navigate( "http://canal22.org/sample0001" ) |
UNTIL !IE.busy AND IE.readyState = 4 |
どうでしょうか。
IE.documentにある種々の情報が取得できましたか。
それでは、応用編というわけではありませんが、
上記のスクリプトをExcelに出力するというスクリプトにしてみましょう。
ExcelとIEの簡単な連携ですね。それではスクリプトです。
IE = CREATEOLEOBJ( "InternetExplorer.Application" ) |
IE.navigate( "http://canal22.org/sample0001" ) |
UNTIL !IE.busy AND IE.readyState = 4 |
EXCEL = CREATEOLEOBJ( "Excel.Application" ) |
EXCEL.range( "A1" ).select() |
EXCEL.activeCell.value= "■ドキュメント" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "タイトル" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.title=" + IE.document.title |
EXCEL.activeCell.offSet(1,-1).select() |
EXCEL.activeCell.value= "ドキュメントタイプ" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.doctype=" + IE.document.doctype |
EXCEL.activeCell.offSet(1,-2).select() |
EXCEL.activeCell.value= "■ベース色" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "背景色" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.bgColor=" + IE.document.bgColor |
EXCEL.activeCell.offSet(1,-1).select() |
EXCEL.activeCell.value= "文字色" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.fgColor=" + IE.document.fgColor |
EXCEL.activeCell.offSet(1,-2).select() |
EXCEL.activeCell.value= "■文字コード" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "文字コード" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.charSet=" + IE.document.charSet |
EXCEL.activeCell.offSet(1,-1).select() |
EXCEL.activeCell.value= "ブラウザのデフォルト文字コード" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.defaultCharset=" + IE.document.defaultCharset |
EXCEL.activeCell.offSet(1,-2).select() |
EXCEL.activeCell.value= "■リンク文字色" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "リンク中の文字色" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.alinkColor=" + IE.document.alinkColor |
EXCEL.activeCell.offSet(1,-1).select() |
EXCEL.activeCell.value= "リンク文字色" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.linkColor=" + IE.document.linkColor |
EXCEL.activeCell.offSet(1,-1).select() |
EXCEL.activeCell.value= "リンク済の文字色" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.vlinkColor=" + IE.document.linkColor |
EXCEL.activeCell.offSet(1,-2).select() |
EXCEL.activeCell.value= "■アンカーオブジェクト" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "アンカーの数" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.anchors.length=" + IE.document.anchors.length |
FOR A = 0 TO (IE.document.anchors.length - 1) |
EXCEL.activeCell.offSet(1,-1).select() |
EXCEL.activeCell.value= "アンカー名(" + A + ")" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.anchors[" + A + "].name=" + IE.document.anchors[A].name |
EXCEL.activeCell.offSet(1,-2).select() |
EXCEL.activeCell.value= "■クッキー" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "クッキー" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.cookie=" + IE.document.cookie |
EXCEL.activeCell.offSet(1,-2).select() |
EXCEL.activeCell.value= "■ドメイン" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "ドメイン名" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.domain=" + IE.document.domain |
EXCEL.activeCell.offSet(1,-1).select() |
EXCEL.activeCell.value= "現在のページのURL" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.URL=" + IE.document.URL |
EXCEL.activeCell.offSet(1,-1).select() |
EXCEL.activeCell.value= "指定座標上のオブジェクト情報(ここではx=100,y=100を指定)" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.elementFromPoint(100,100)=" + IE.document.elementFromPoint(100,100) |
IE.document.links[0].click() |
UNTIL !IE.busy AND IE.readyState = 4 |
EXCEL.activeCell.offSet(1,-2).select() |
EXCEL.activeCell.value= "■リファラ" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "リファラ" |
EXCEL.activeCell.offSet(1,1).select() |
EXCEL.activeCell.value= "IE.document.referrer=" + IE.document.referrer |
IE.navigate( "http://canal22.org/sample0001" ) |
UNTIL !IE.busy AND IE.readyState = 4 |