Regex with inner HTML

Tagged: 

This topic contains 1 reply, has 1 voice, and was last updated by  Marco Shaw 3 years, 9 months ago.

  • Author
    Posts
  • #12004

    Marco Shaw
    Participant

    I'm trying to scrape a page. It seems the page doesn't work well unless one uses cookies, so I decided to try to use the IE COM object.

    Things seem to be fine, but then I try to use a regex to pull out information, and it always seems to be blank. I've also tried [string] instead of tostring().

    Anything obvious that I would be missing when trying to use the regex below?

    $ie=new-object -com internetexplorer.application
    $ie.visible=$true
    $ie.navigate("http://forums.udacity.com/tags/ud617/#ud617")
    [regex]::matches('$ie.document.body.innerhtml.tostring()','http://forums.udacity.com/users/\d+/(\w+)')

  • #12006

    Marco Shaw
    Participant

    Solved: Don't use quotes in the first element of the matches method.

    [regex]::matches($ie.document.body.innerhtml.tostring(),'http://forums.udacity.com/users/\d+/(\w+)')

You must be logged in to reply to this topic.