「20090418_001_03」の編集履歴(バックアップ)一覧はこちら
「20090418_001_03」(2009/04/18 (土) 21:53:41) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
<p><br /><br />
===<br /><br />
===</p>
<p><br /><br />
===<br /><br />
Dim s</p>
<p>txt_File01 = "file001.txt"<br />
txt_File02 = "file002.txt"<br />
txt_File03 = "file003.txt"</p>
<p>'txt_Regexp_Pattern01 = "class=r><a
href=""[a-zA-Z1-90/&%=_\.\?\+\:\-;]+""" ' 検索対象文字列</p>
<p>txt_Regexp_Pattern01 = "href=" ' 検索対象文字列<br />
txt_Regexp_Pattern01 = "href=""[a-zA-Z1-90/&%=_\.\?\+\:\-;]+""" '
検索対象文字列</p>
<p><br />
'WScript.Echo txt_Regexp_Pattern01</p>
<p>url_Val01 = "<a href="http://www.google.com/">http://www.google.com/</a>"<br />
url_Val02 = "yourfilehost 声 でちゃう site:bbspink.com"</p>
<p>url_CurPath = "C:\Documents and Settings\user\My Documents\Work\w002\"</p>
<p>'対象画面を検索、なければ開く(必要に応じ使用してください)<br />
Set xShell = CreateObject("Shell.Application")<br />
win_s = False<br />
For Each Window In xShell.Windows '対象URLが表示されているか?<br />
If TypeName(Window.Document) = "HTMLDocument" Then<br />
if Window.Document.url=url_Val01 then<br />
Set objIE0 = Window '対象URLが表示→その画面を使う<br />
win_s=true<br />
exit for<br />
end if<br />
end if<br />
next</p>
<p>if win_s=false then '対象URLが非表示→新しく画面を開く</p>
<p> Set objIE0 = CreateObject("InternetExplorer.Application")<br />
objIE0.Visible = True<br />
objIE0.Navigate url_Val01</p>
<p> Do While objIE0.busy = True<br />
'空ループだと無駄にCPUを使うので250ミリ秒のインターバルを置く<br />
WScript.sleep(250)<br />
Loop</p>
<p> Do While objIE0.document.readyState <> "complete"<br />
Loop<br />
end if<br />
'---header end---</p>
<p>'---以下操作コード、必要な部分をコピーしてください---<br />
'objIE0.document.all.q.value=url_Val02 ' text index=2<br />
'objIE0.document.all.Submit.click ' submit Submit ログイン or
tags("INPUT").item(4).Click</p>
<p>on error resume next</p>
<p>'objIE0.document.form1.yourfilehosturl.value=url_Val02 ' text index=2<br />
objIE0.document.f.q.value=url_Val02 ' text index=2</p>
<p>'objIE0.document.all.Submit.click ' submit Submit ログイン or
tags("INPUT").item(4).Click<br />
'objIE0.document.form1.Submit.click ' submit Submit ログイン or
tags("INPUT").item(4).Click</p>
<p>'objIE0.document.gs.Submit.click ' submit Submit ログイン or
tags("INPUT").item(4).Click</p>
<p>objIE0.document.f.Submit.click ' submit Submit ログイン or
tags("INPUT").item(4).Click</p>
<p> Do While objIE0.busy = True<br />
'空ループだと無駄にCPUを使うので250ミリ秒のインターバルを置く<br />
WScript.sleep(250)<br />
Loop</p>
<p> Do While objIE0.document.readyState <> "complete"<br />
Loop</p>
<p><br />
Set objFso02 = CreateObject("Scripting.FileSystemObject")</p>
<p>Set objFile02 = objFso02.OpenTextFile(url_CurPath & txt_File02, 2,
True)</p>
<p>strBody = objIE0.Document.Body.InnerHtml</p>
<p>'objFile02.WriteLine "aaa " & vbcrlf & vbcrlf &
objIE0.Document.Body.InnerText<br />
objFile02.WriteLine "aaa " & vbcrlf & vbcrlf & strBody</p>
<p><br />
Dim objRegExp ' 正規表現オブジェクト<br />
Dim objMatches ' 検索結果<br />
Dim objMatch ' 検索結果<br />
Dim strMessage ' 表示メッセージ</p>
<p>Set objRegExp = New RegExp ' 文字列検索・置換用オブジェクトの作成<br />
with objRegExp<br />
.Global = True ' 文字列全体を検索するように指定</p>
<p> .Pattern = txt_Regexp_Pattern01</p>
<p> .IgnoreCase = True</p>
<p> Set objMatches = .Execute(strBody)</p>
<p><br />
end with</p>
<p><br />
objFile02.WriteLine "=================================="<br />
objFile02.WriteLine "=================================="<br />
objFile02.WriteLine "=================================="</p>
<p>i = 0</p>
<p>For Each objMatch In objMatches</p>
<p> i = i + 1<br />
objFile02.WriteLine objMatch.Value</p>
<p>Next</p>
<p>objFile02.Close<br />
Set objFile02 = Nothing<br />
Set objFso02 = Nothing</p>
<p> </p>
<p>WScript.Echo i<br /><br /><br /><br />
===</p>