1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Option Explicit
Dim oIE,oFSO,oFile,oColTag,oItem,Result,URL,OutPutFile,Count,ws
URL = " http://www.developpez.net/forums/d1628719/autres-langages/general-visual-basic-6-vbscript/vbscript/script-va-recuperer-contenu-balise-strong-d-page-html/"
OutPutFile = "OutPut_Strong.txt"
Set oIE = CreateObject("InternetExplorer.Application")
Set oFSO = Createobject("Scripting.FileSystemObject")
set ws = CreateObject("wscript.shell")
oIE.Visible = False
oIE.Navigate URL
Do Until oIE.ReadyState = 4
WScript.Sleep 500
Loop
Count = 0
Set oColTag = oIE.Document.getElementsByTagName("strong")
If oColTag.length > 0 Then Set oFile = oFSO.OpenTextFile(OutPutFile,2,True)
For Each oItem In oColTag
Count = Count + 1
oFile.WriteLine Lpad(Count,2) & " . "& oItem.innerText & oFile.WriteLine
Next
oIE.Quit()
If IsObject(oFile) Then oFile.Close
ws.run OutPutFile
'*********************************************************************************
Function LPad(ByVal v, ByVal l)
If Len(v) > l Then l = Len(v)
LPad = Right(String(l,"0") & v, l)
End Function
'********************************************************************************* |
Partager