-
-
Save mlhaufe/1568244 to your computer and use it in GitHub Desktop.
'Reference: <http://www.visualbasicscript.com/tm.aspx?high=&m=95638&mpage=1> | |
Option Explicit | |
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject") | |
Dim files : Set files = fso.GetFolder("C:\test\").Files | |
Dim file | |
For Each file In files | |
If file.Type = "Firefox Document" Then '<-- update for your system | |
Dim doc : Set doc = CreateObject("htmlfile") | |
doc.write fso.OpenTextFile(file.Path).ReadAll() | |
WScript.Echo doc.title | |
doc.title = doc.title & " (Modified)" | |
WScript.Echo doc.documentElement.outerHTML | |
End If | |
Next |
@iisboy I forgot what this script was created for as the referenced website no longer exists. This script was first written for Windows 2000 and still works in Windows 10.
If you can use Powershell instead then you should:
ls -Recurse *.html | % {
$html = New-Object -Com 'HTMLFile'
$html.IHTMLDocument2_write($(gc $_ -Raw))
# $html is the DOM so the normal properties and methods work
Write-Host "Path $($_.FullName)"
Write-Host "Title: $($html.title)"
}
@iisboy I forgot what this script was created for as the referenced website no longer exists. This script was first written for Windows 2000 and still works in Windows 10.
If you can use Powershell instead then you should:
ls -Recurse *.html | % { $html = New-Object -Com 'HTMLFile' $html.IHTMLDocument2_write($(gc $_ -Raw)) # $html is the DOM so the normal properties and methods work Write-Host "Path $($_.FullName)" Write-Host "Title: $($html.title)" }
thanks for your reply. i want help for you a copy of code ,i test in windows 7 have a little bug,this is below:
`dim strJson,myJson
strJson="{ ""access_token"":""ACCESS_TOKEN"", ""expires_in"":7200, ""refresh_token"":""REFRESH_TOKEN"", ""openid"":""OPENID"", ""scope"":""SCOPE"" }"
set doc = CreateObject("htmlfile")
doc.write ""
set JSON = doc.frames.JSON
set obj = JSON.parse(strJson)
'myJson=JSON.stringify(obj)
Response.Write obj.access_token
retrun value :
Microsoft VBScript ����ʱ���� ���� '800a01b6'
����֧�ִ����Ի�: 'doc.frames.JSON'
/123_fun/1.asp���� 13`
@iisboy I believe "htmlfile" is equivalent to Internet Explorer 6, and therefore supports ECMAScript version 3. Which means no JSON object.
Perhaps using a 3rd party library would help?
this code support all version os?