Getting text from html (allElements)

This topic contains 2 replies, has 2 voices, and was last updated by  Tony Antony 3 months ago.

  • Author
    Posts
  • #74954

    Tony Antony
    Participant

    I have a script that I use to login to a website, and it's working. For my next step, I need to get a link from the

    $login.AllElements

    The text I need is

    administration/uploadprofileselector.aspx?l=English&uid=1234&oid=123456

    How would I capture it from this?

    $login.AllElements

    innerHTML : Main Menu
    ......more html stuff....
    item title="Transfer In And Out" url="reports/TransferInAndOut2.asp?l=English"
    item title="Seize Items" url="administration/SeizeReport.asp?l=English"
    item title="File Upload Utility" url="administration/uploadprofileselector.aspx?l=English&uid=1234&oid=123456" >

    Thanks,

    Tony

  • #74969

    Don Jones
    Keymaster

    I can't even tell you how much I hate the Internet Explorer COM object. This isn't really a PowerShell question, understand, so you might also want to ask in a more dev-centric forum like StackOverflow. This COM object is also a little flakey in .NET, so be prepared to bang your head against a wall a bit.

    AllElements is a collection; it doesn't have an innerHTML of its own. You might have better luck using getElementsByName(); you can get the named elements you want (e.g., their HTML tag name), and enumerate through that collection. But you can't pull innerHTML from a collection – you have to get an actual concrete element in order to use that.

    If you just start with AllElements, you're going to have to enumerate that. If you pull the innerHTML for the entire page, you've just got a giant wedge of text and you're going to end up using a regular expression to match whatever you want, and it's going to be a lot harder.

  • #74975

    Tony Antony
    Participant

    Thanks Don,

    We have to upload some files to a website each morning, so I'm trying to automate that using PowerShell.
    Thanks for the reply, I'll look into it.

    Thanks,

    Tony

You must be logged in to reply to this topic.