Created
July 3, 2013 14:32
-
-
Save ejb1123/5918456 to your computer and use it in GitHub Desktop.
changes web browser souce
This file contains hidden or 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
Private strNewTitle As String = "New Title" 'Whatever value is going between the tags, a title in this case | |
Private strTag As String = "title" 'The tag to look for | |
Private Sub webOriginal_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles webOriginal.Navigated | |
Dim strSource As String = webOriginal.DocumentText.ToLower 'Get the source | |
Dim iPos As Integer = 0 'Position counter (if replacing all tag occurrences) | |
Dim strStartTag As String = "<" & strTag & ">" 'Form the start and end tags | |
Dim strEndTag As String = "</" & strTag & ">" | |
'Use a loop if we want to replace all occurrences | |
Do | |
'Figure out where to begin | |
Dim iBeg As Integer = strSource.IndexOf(strStartTag) | |
'Figure out where our </tag> starts, adjust to get the correct end position | |
Dim iEnd As Integer = strSource.IndexOf(strEndTag) + strTag.Length + 3 | |
iPos = iEnd 'This is where we'll pick up next time if looking for other occurrences | |
'Get the <tag> we're looking for and whatever is in between | |
Dim strTitleFull As String = strSource.Substring(iBeg, iEnd - iBeg) | |
'Just give ourselves a not of what was found | |
Debug.WriteLine("Found: " & strTitleFull) '"<" & strTag & ">" & strNewTitle & "</" & strTag & ">" | |
'Replace it with what we've specified | |
strSource = strSource.Replace(strTitleFull, strStartTag & strNewTitle & strEndTag) | |
'Take a look at it in its entirety | |
txtSource.Text = strSource | |
Loop Until iPos >= strSource.LastIndexOf(strEndTag) | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment