none
How to output the innerText into file? RRS feed

  • Question

  • Referring to above image, I would like to know on how to output the innerText on following coding as shown below

    Does anyone have any suggestions?
    Thanks in advance for any suggestions

    $loginUrl = "http://www.google.com";
    #initialize browser
    $ie = New-Object -com internetexplorer.application;
    $ie.visible = $true;
    $ie.navigate($loginUrl);
    while ($ie.Busy -eq $true) { Start-Sleep -Seconds 1; }    #wait for browser idle
    ($ie.document.getElementsByName("q") |select -first 1).value = "k";
    $ie.document.getElementsByTagName("q") | select -ExpandProperty innertext|%{"K$_"}
    foreach ($element in $ie.document.getElementsByTagName('b'))
    {
        Write-Host $element.innerText
    }


    Thanks in advance for any suggestions


    • Edited by oemMicrosoft Saturday, February 17, 2018 5:52 AM
    Saturday, February 17, 2018 5:52 AM

Answers

All replies

  • http://www.vb-tips.com/MSHTML.aspx

    Success
    Cor


    • Edited by Cor Ligthert Saturday, February 17, 2018 1:12 PM
    Saturday, February 17, 2018 8:05 AM
  • http://www.vb-tips.com/Shell.aspx

    Referring to following coding, I would like to know on whether it is PowerShell or VBA language or other.

    Do you have any suggestions?
    Thank you very much for any suggestions (^v^)

    Public Class Form1
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            'This code can be placed in any class or module to let it work.
            Dim p As New Process
            Dim pi As New ProcessStartInfo
            pi.UseShellExecute = False
            pi.RedirectStandardOutput = True
            pi.Arguments = "www.google.com"
            pi.WorkingDirectory = "C:\\windows\\system32"
            'this for nt* computers
            pi.Filename = "ping"
            p.StartInfo = pi
            p.Start()
            Dim sr As IO.StreamReader = p.StandardOutput
            Dim sb As New System.Text.StringBuilder("")
            Dim input As Integer = sr.Read
            Do Until input = -1
                sb.Append(ChrW(input))
                input = sr.Read
            Loop
            MessageBox.Show (sb.ToString)
        End Sub
    End Class


    Thanks in advance for any suggestions

    Saturday, February 17, 2018 8:57 AM
  • VB Net

    Success
    Cor

    Saturday, February 17, 2018 9:08 AM
  • Can VB Net work under Excel?

    Furthermore, do your suggested link relate to collect the innerText and output into text file?

    Do you have any sugestions?

    Thank you very much for any suggestions


    Thanks in advance for any suggestions

    Saturday, February 17, 2018 9:33 AM
  • You've obvious set your question in the wrong forum. 

    VBA is this one.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=isvvba


    Success
    Cor

    Saturday, February 17, 2018 9:40 AM
  • My issue is to collect the innerText and output into text file, which one (VBA or VB) is more appropriated approach?

    Do you have any sugestions?

    Thank you very much for any suggestions


    Thanks in advance for any suggestions


    • Edited by oemMicrosoft Saturday, February 17, 2018 9:44 AM
    Saturday, February 17, 2018 9:43 AM
  • First off the following advice most examples will be in C# when looking for details and examples. So if this may be a show stopper but wanted to put it out there anyways.

    I would suggest looking a selenium webdriver (there are drivers for the popular browsers) for listening to events from the DOM (Document Object Model) and HTML Agility pack (HAP) for obtaining li element values.

    selenium webdriver

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Saturday, February 17, 2018 12:23 PM
    Moderator
  • Sorry, 

    I gave you the wrong link, it had to be this one

    http://www.vb-tips.com/MSHTML.aspx

    Be aware this way is not so easy anymore (it still goes on Windows 10)

    Better to take the agilty pack as Karen shows.


    Success
    Cor



    Saturday, February 17, 2018 1:13 PM
  • Visual Base Studio is not installed on my PC, I would like to know on how to run your suggested coding without VB Studio or if VB studio is required, then where can I download the latest version for testing?

    Furhtermore, do I need to install HTML Agility pack (HAP) as well?

    Do you have any suggestions?
    Thanks, to everyone very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Saturday, February 17, 2018 1:30 PM
  • Visual Studio Community 2017 is a freeware version (it has restricted deployment rights, but I find it very complex what that is)

    https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15


    Success
    Cor

    Saturday, February 17, 2018 1:49 PM
  • Installation is just finished, but I am using Win 7 Home, not Win 10.

    Do you have older version for download? which is compatible with Win 7

    Do you have any suggestions?
    Thanks, to everyone very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Saturday, February 17, 2018 3:35 PM
  • W7 should be fine

    Success
    Cor

    Saturday, February 17, 2018 3:39 PM
  • After installing Visual Studio Community 2017 (15.5.6), would it be enough to run program?

    Do I need to install Visual Studio Professional 2017 as well?

    Do you have any suggestions?
    Thanks, to everyone very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Saturday, February 17, 2018 3:57 PM
  • No Community is enough, but you have to register it (free). 


    Success
    Cor

    Saturday, February 17, 2018 4:01 PM
  • There are error during compile as shown below:

    Do you have any suggestions?
    Thank you very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Sunday, February 18, 2018 7:04 AM
  • That is because it is a very old sample, if you copy and paste it blank lines are added, you have to remove those.


    Success
    Cor

    Sunday, February 18, 2018 10:24 AM
  • After removing black line, there are error messages as shown below

    Do you have any suggestions?
    Thank you very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Sunday, February 18, 2018 3:30 PM
  • As far as I can see you did not add the MSHTML reference. I did not use it a while, but when you have Windows 10 then look at this page where solutions are given.

    https://stackoverflow.com/questions/31853699/mshtml-dll-on-windows-10

    However, don't forget this in your code

       'The line bellow will give an error in Frameworks higher than 2.0

            'To overcome that you have to show all files using Solution Explorer 

            'And set in the mshtml properties Embeded Interop type to false.

            Doc = New mshtml.HTMLDocumentClass


    Success
    Cor

    Sunday, February 18, 2018 5:22 PM
  • I follow the given instruction, and still get error as shown below

    Do you have any suggestions on what wrong it is?
    Thank you very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Monday, February 19, 2018 4:11 AM
  • Do you have any suggestions on what wrong it is?
    Thank you very much for any suggestions (^v^)

    Thanks in advance for any suggestions

    Wednesday, February 21, 2018 11:10 AM
  • Does anyone have any suggestions?
    Thanks, to everyone very much for any suggestions (^v^)

    Thanks in advance for any suggestions

    Wednesday, February 21, 2018 3:50 PM
  • Referring to above image, I would like to know on how to retrieve the innerText and output into a text file.

    Does anyone have any suggestions?
    Thanks in advance for any suggestions


    Thanks in advance for any suggestions

    Wednesday, February 21, 2018 3:55 PM
  • There is no image so pretty much impossible to help.

    Lloyd Sheen

    Wednesday, February 21, 2018 4:34 PM
  • I think my previous reply was to difficult, (not your fault has to do with MSHTML). 

    But this goes in fact as well

    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            WebBrowser1.Navigate("www.Google.com")
        End Sub
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim elem As HtmlElement
            If WebBrowser1.Document IsNot Nothing Then
                Dim elems As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("HTML")
                If elems.Count = 1 Then
                    elem = elems(0)
                    Dim pageSource = elem.InnerHtml
                    TextBox1.Text = pageSource
                End If
            End If
        End Sub
    End Class

    Same visual studio so that you did not do for nothing


    Success
    Cor

    Wednesday, February 21, 2018 5:07 PM

  • Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            WebBrowser1.Navigate("www.Google.com")
        End Sub
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim elem As HtmlElement
            If WebBrowser1.Document IsNot Nothing Then
                Dim elems As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("HTML")
                If elems.Count = 1 Then
                    elem = elems(0)
                    Dim pageSource = elem.InnerHtml
                    TextBox1.Text = pageSource
                End If
            End If
        End Sub
    End Class



    I follow the given instruction, and still get error as shown below

    Do you have any suggestions on what wrong it is?
    Thank you very much for any suggestions (^v^)



    Thanks in advance for any suggestions

    Thursday, February 22, 2018 8:32 AM
  • You have not dragged a webbrowser, a textbox (which property multiline should be set to true) and 2 buttons on the form. 

    Success
    Cor

    Thursday, February 22, 2018 9:12 AM
  • You have not dragged a webbrowser, a textbox (which property multiline should be set to true) and 2 buttons on the form. 

    I have created webbrowser, a textbox and 2 buttons on the form as shown below, but how can I relate textbox and 2 buttons to google's page textbox and 2 buttons as shown below?

    Do you have any suggestions?
    Thank you very much for any suggestions (^v^)


    Thanks in advance for any suggestions

    Thursday, February 22, 2018 9:47 AM
  • It seems you succeeded in what you asked and want to do a next step. 

    In these forum persons mark then all replies from contributors who helped them to find the answer as answer, vote the helpful posts and make a new question. 



    Success
    Cor

    Thursday, February 22, 2018 1:07 PM
  • My original question is to retrieve the innertext and output into text file, drawing the form may be part of the process, but at this moment, Innertext still cannot be retrieved and output into text file yet.

    Do you have any suggestions?
    Thank you very much for any suggestions (^v^)


    Thanks in advance for any suggestions


    • Edited by oemMicrosoft Thursday, February 22, 2018 4:28 PM
    Thursday, February 22, 2018 4:28 PM
  • My original question is to retrieve the innertext and output into text file, drawing the form may be part of the process, but at this moment, Innertext still cannot be retrieved and output into text file yet.

    Do you have any suggestions?
    Thank you very much for any suggestions (^v^)


    Thanks in advance for any suggestions


    Try my example, and don't change it, if you run it is the first button to get the page and the second button to put the innertext in the textbox.  

    Success
    Cor

    Thursday, February 22, 2018 4:32 PM
  • I wrote this before.

    It seems you succeeded in what you asked and want to do a next step. 

    In these forum persons mark then all replies from contributors who helped them to find the answer as answer, vote the helpful posts and make a new question. 

    However, this seems to be to much work for you. 

    Therefore


    Success
    Cor


    Friday, February 23, 2018 12:03 PM

  • Thanks, to everyone very much for suggestions (^v^)


    Thanks in advance for any suggestions


    Friday, February 23, 2018 3:57 PM