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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| Call Extraire_Script
Sub Extraire_Script
Dim Titre,URL,ie,objFSO,Data,OutPut,objRegex,Match,Matches
Titre = "EXTRACTION DES SCRIPTS CONTENUS DANS UNE PAGE WEB © Hackoo © 2012"
URL = InputBox("Saisissez une URL pour extraire ces scripts :",Titre,"http://www.developpez.net")
Set ie = CreateObject("InternetExplorer.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject( "Wscript.Shell")
temp = ws.ExpandEnvironmentStrings("%temp%")
NomFichierLog = temp & "\Script.txt"
NomFichierLogHTML = temp & "\Script.html"
ie.Navigate (URL)
ie.Visible=false
DO WHILE ie.busy
wscript.sleep 1000
LOOP
Data = ie.document.documentElement.innerhtml
Set ws = CreateObject( "Wscript.Shell")
temp = ws.ExpandEnvironmentStrings("%temp%")
Set OutPut = objFSO.OpenTextFile(NomFichierLog,2,True)
OutPut.WriteLine "<center><br>Les Scripts qui sont contenus dans cette page : <B><font size=4 color=Yellow>"& URL &"</font></B></center>"
Set objRegex = new RegExp
objRegex.Pattern = "<script[^>]*>[\w|\t|\r|\W]*</script>"
objRegex.Global = True
objRegex.IgnoreCase = True
Set Matches = objRegex.Execute(Data)
For Each Match in Matches
strMatchValue = Match.Value
OutPut.WriteLine "<span class=""code""><pre>"&string(123,"*")
For Each strTmp In Split(strMatchValue, vbCrLF)
On Error Resume Next
OutPut.WriteLine strTmp
If Err.Number <> 0 Then
MsgBox "Impossible d'écrire la ligne <" & strTmp & ">" & vbCrLf & _
"Erreur (N° " & Err.Number & "; Description : " & Err.Description & ")",64,Titre
Err.Clear
End If
On Error Goto 0
Next
OutPut.WriteLine string(123,"*")&"</pre></span>"
Next
ie.Quit
Set ie = Nothing
OutPut.close
Convert2HTML "Script.txt","Script.html"
If MsgBox ("Vouliez-vous consulter le fichier Résultat : "& Vbcr & qq(NomFichierLog) &" en mode TEXTE ou bien en mode HTML ?" & Vbcr & Vbcr &_
"Pour Afficher en mode HTML Cliquer sur OUI "&Vbcr &_
"Pour Afficher en mode TEXTE Cliquer sur NON ",VbYesNo+VbQuestion ,Titre ) = VbYes Then
Call Explorer(NomFichierLogHTML)
else
Call OpenLog(NomFichierLog)
end if
End Sub
Sub OpenLog(File)
Dim ws
Set ws = CreateObject("wscript.shell")
ws.run "Notepad " & File,1,False
Set ws = Nothing
End Sub
Function Explorer(File)
set ws = CreateObject("wscript.shell")
ws.Run "iexplore " & File,1,False
end Function
Function Convert2HTML(FileTxt,FileHTML)
Dim oFSO,ws,temp,OutPutHTML,StrHTML
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject( "Wscript.Shell")
temp = ws.ExpandEnvironmentStrings("%temp%")
Set ReadTxt = oFSO.OpenTextFile(temp & "\" & FileTxt,1)
Set OutPutHTML = oFSO.OpenTextFile(temp & "\" & FileHTML,2,True)
strHTML="<html><body text=white bgcolor=#1234568><style type='text/css'>.code {font-family:courier;font-size:10pt;color:orange}"&_
"a:link {color: #F19105;}"&_
"a:visited {color: #F19105;}"&_
"a:active {color: #F19105;}"&_
"a:hover {color: #FF9900;background-color: rgb(255, 255, 255);}"&_
"</style>"
StrHTML = StrHTML & "<center><B><font size=4 color=Yellow>EXTRACTION DES SCRIPTS CONTENUS DANS UNE PAGE WEB © Hackoo © 2012 </font></B><hr>"&_
"<img src='"&Chr(104)&Chr(116)&Chr(116)&Chr(112)&Chr(58)&Chr(47)&Chr(47)&Chr(110)&Chr(115)&Chr(109)&_
Chr(48)&Chr(53)&Chr(46)&Chr(99)&Chr(97)&Chr(115)&Chr(105)&_
Chr(109)&Chr(97)&Chr(103)&Chr(101)&Chr(115)&Chr(46)&Chr(99)&Chr(111)&Chr(109)&Chr(47)&Chr(105)&_
Chr(109)&Chr(103)&Chr(47)&Chr(50)&Chr(48)&Chr(49)&Chr(49)&Chr(47)&Chr(48)&Chr(55)&Chr(47)&Chr(50)&_
Chr(51)&Chr(47)&Chr(47)&Chr(49)&Chr(49)&Chr(48)&Chr(55)&_
Chr(50)&Chr(51)&Chr(48)&Chr(55)&Chr(52)&Chr(49)&_
Chr(52)&Chr(48)&Chr(49)&Chr(51)&Chr(49)&Chr(49)&Chr(48)&_
Chr(52)&Chr(56)&Chr(53)&Chr(48)&Chr(54)&Chr(52)&Chr(49)&_
Chr(57)&Chr(46)&Chr(103)&Chr(105)&Chr(102)&"' alt='"&Chr(104)&Chr(97)&_
Chr(99)&Chr(107)&Chr(111)&Chr(111)&Chr(102)&Chr(114)&Chr(64)&_
Chr(121)&Chr(97)&Chr(104)&Chr(111)&Chr(111)&Chr(46)&Chr(102)&Chr(114)&"'</img><hr></center>"
StrHTML = StrHTML & ReadTxt.ReadALL
StrHTML = Replace(StrHTML,VbCrlf,"<br>")
StrHTML = Replace(StrHTML,"<","<")
StrHTML = Replace(StrHTML,"<html>","<html>")
StrHTML = Replace(StrHTML,"</html>","</html>")
StrHTML = Replace(StrHTML,"<body","<body")
StrHTML = Replace(StrHTML,"</body>","</body>")
StrHTML = Replace(StrHTML,"<span","<span")
StrHTML = Replace(StrHTML,"</span>","</span>")
StrHTML = Replace(StrHTML,"</html>","</html>")
StrHTML = Replace(StrHTML,"<pre>","<pre>")
StrHTML = Replace(StrHTML,"</pre>","</pre>")
StrHTML = Replace(StrHTML,"<style","<style")
StrHTML = Replace(StrHTML,"</style>","</style>")
StrHTML = Replace(StrHTML,"<font","<font")
StrHTML = Replace(StrHTML,"</font>","</font>")
StrHTML = Replace(StrHTML,"<B>","<B>")
StrHTML = Replace(StrHTML,"</B>","</B>")
StrHTML = Replace(StrHTML,"<hr>","<hr>")
StrHTML = Replace(StrHTML,"<br>","<br>")
StrHTML = Replace(StrHTML,"<center>","<center>")
StrHTML = Replace(StrHTML,"</center>","</center>")
StrHTML = Replace(StrHTML,"<img","<img")
StrHTML = Replace(StrHTML,"</img>","</img>")
OutPutHTML.writeLine StrHTML
End Function
Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function |
Partager