コメント |
1) そのページのソースを右クリックで表示して、拡張子 .htm で保存
2) その中で欲しい情報のある部分の親エレメントに id を書き込む( 無ければ id 付き DIV で囲む )
3) 以下のソースの [[softlink.htm]] 部分が保存した HTML( スクリプトと同じ場所 )
4) 以下のスクリプトは、アンカーよりタイトルと href を取得して insert 文を作成している
5) data.txt が出来上がった SQL なので、実行したい DB の キャラクタセットに変換する
6) この例では、リモートの phpMyAdmin で実行。
※ リモートの HTML のフォーマットが固定であれば、自動化も可能。
@DIV
<JOB>
<COMMENT>
************************************************************
WSH 実行スケルトン
************************************************************
</COMMENT>
<COMMENT>
************************************************************
外部スクリプト定義
************************************************************
</COMMENT>
<SCRIPT
language="VBScript"
src="http://lightbox.in.coocan.jp/laylaClass.vbs">
</SCRIPT>
<SCRIPT language=VBScript>
' ***********************************************************
' 処理開始
' ***********************************************************
Call laylaLoadFunction( "http://lightbox.in.coocan.jp/baseFunction.vbs" )
Call laylaLoadFunction( "http://lightbox.in.coocan.jp/toolFunction.vbs" )
LoadIEUrlDocument( "file:///" & ScriptDir & "\softlink.htm" )
Set objTarget = IEDocument.document.getElementById("target")
Set colA = objTarget.getElementsByTagName("A")
strValue = ""
nSeq = 100
For Each obj In colA
strValue = strValue & "insert into `links` (MID,TYPE,SEQ,TITLE,URL) values('softlink',200,"
strValue = strValue & nSeq
strValue = strValue & "," & Ss(obj.innerText)
strValue = strValue & "," & Ss(obj.getAttribute("href"))
strValue = strValue & ");" & vbCrLf
nSeq = nSeq + 10
Next
Call PutTextFile( "data.txt", strValue )
</SCRIPT>
</JOB>
@END
|