-
-
Save Linda-chan/443a8cbbc60fc6f6ed5d6829e5d1e404 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
DefObj A-Z | |
'==================================================================== | |
Public Sub Main() | |
Dim HTML As HTMLDocument | |
Dim HTML_ As Object | |
Dim TXT As BStr | |
Set HTML = New HTMLDocument | |
Set HTML_ = HTML | |
TXT = GetSourceFile() | |
HTML.Clear | |
HTML_.write TXT | |
MsgBox HTML.documentElement.innerHTML | |
FixLinks HTML | |
MsgBox HTML.documentElement.innerHTML | |
End Sub | |
'==================================================================== | |
Private Sub FixLinks(ByRef HTML As HTMLDocument) | |
Dim Nodes As IHTMLDOMChildrenCollection | |
Dim Node As IHTMLAnchorElement | |
Dim TMP As Long | |
Dim TXT As BStr | |
Set Nodes = HTML.querySelectorAll("A") | |
'MsgBox Nodes.Length | |
For TMP = 0 To Nodes.Length - 1 | |
Set Node = Nodes(TMP) | |
TXT = Node.href | |
'MsgBox Len(TXT) & " :: «" & TXT & "»" | |
TXT = csReReplace(TXT, "^(http)s?(://p\.example\.com)(/)", "$1$2.local$3") | |
'MsgBox Len(TXT) & " :: «" & TXT & "»" | |
Node.href = TXT | |
Next TMP | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment