none
help get html source code chrome RRS feed

  • Question

  • hello

    how get html source code chrome vb.net

    i have code

    This code get title
     I'm want to get the source code

    Is there a way or solution to get the source code from 

    chrome

           '//Grab all the Chrome processes
            Dim chrome() As Process = Process.GetProcessesByName("chrome")
    
            '//Exit if chrome isn't running
            If chrome.Length <= 0 Then Exit Sub
    
            For Each chromeProcess As Process In chrome
    
                '//If the chrome process doesn't have a window handle then ignore it
                If chromeProcess.MainWindowHandle <> IntPtr.Zero Then
    
                    '//To find the tabs we first need to locate something reliable - the 'New Tab' button
                    Dim rootElement As AutomationElement = AutomationElement.FromHandle(chromeProcess.MainWindowHandle)
                    Dim condNewTab As Condition = New PropertyCondition(AutomationElement.NameProperty, "New Tab")
                    Dim elemNewTab As AutomationElement = rootElement.FindFirst(TreeScope.Descendants, condNewTab)
    
                    '//Get the tabstrip by getting the parent of the 'new tab' button
                    Dim tWalker As TreeWalker = TreeWalker.ControlViewWalker
                    Dim elemTabStrip As AutomationElement = tWalker.GetParent(elemNewTab)
    
                    '//Loop through all the tabs and get the names which is the page title
                    Dim tabItemCondition As Condition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem)
                    For Each tabItem As AutomationElement In elemTabStrip.FindAll(TreeScope.Children, tabItemCondition)
                        Dim HTML As New mshtml.HTMLDocument
                        MsgBox(tabItem.Current.Name)
                    Next
    
                End If
            Next

    Thursday, August 1, 2019 10:36 AM

All replies

  • Be aware you have to understand reading C# which is for most VB net programmmers a piece of cake.

    https://www.google.com/chrome/dev/


    Success
    Cor

    Thursday, August 1, 2019 2:03 PM
  • Hi,

    get html source code

       Public Function getwebcode(ByVal url As String) As String
            Dim myWebClient As WebClient = New WebClient()
            Dim myDataBuffer As Byte() = myWebClient.DownloadData(url)
            Dim SourceCode As String = Encoding.GetEncoding("UTF-8").GetString(myDataBuffer)
            Return SourceCode
        End Function

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 2, 2019 2:52 AM
    Moderator