printing out the URL of each frame in html

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 15 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
jstein
Posts: 3
Last visit: Thu Apr 10, 2008 1:53 pm

printing out the URL of each frame in html

Post by jstein »

I need help printing out the url of frames in an html document. Below is my script (foo.ps1) which prints the url of the document (foo.html). I have spent a couple of hours trying to add the appropriate code to access the url of the documents within the frames. I have tries stuff like:@($doc.frames)[0].document.url@($doc.frames)[test].document.url$doc.getElementById("test").document.urletc etc etcI would appreciate anyones help in the proper code needed to access the objects/elements within the frame of a html document.foo.ps1#########################$ie = new-object -comobject "InternetExplorer.Application"$ie.visible = $true$ie.navigate("file:///C:/Users/Jason/Desktop/foo.html")start-sleep -m 1000$doc=$ie.document$doc.url#########################foo.html**************************************<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"><HTML><HEAD><TITLE>My Framz Page- The Master Page</TITLE><META http-equiv=Content-Type content="text/html; charset=windows-1252"><META content="MSHTML 6.00.6000.16643" name=GENERATOR></HEAD><FRAMESET cols=50%,50%><FRAME NAME=test id=test src="http://www.pagetutor.com/frames_tutor/e ... ml"><FRAME src="http://www.pagetutor.com/frames_tutor/e ... SET></HTML>***********************************************************************
User avatar
donj
Posts: 416
Last visit: Thu May 29, 2008 5:08 am

printing out the URL of each frame in html

Post by donj »

YOu might consider changing the way you do this entirely - it might be easier just to get the base document and use a regex to grab the src's from the HTML tags. Then load each page individually. IE has a lot of security surrounding frames that can make them pretty complex, and the COM object doesn't adapt 100% well into .NET.
User avatar
jstein
Posts: 3
Last visit: Thu Apr 10, 2008 1:53 pm

printing out the URL of each frame in html

Post by jstein »

Hey Jvieera,Tried to access frame but was unable to get anywhere even with a local page. Thanks for the suggestions.
User avatar
jstein
Posts: 3
Last visit: Thu Apr 10, 2008 1:53 pm

printing out the URL of each frame in html

Post by jstein »

Hey All,I was able to finally do it with the help you two provided. My new script is as follow:##########################################################$ie = new-object -comobject "InternetExplorer.Application"$ie.visible = $true$ie.navigate("file:///C:/Users/Jason/Desktop/foo.html")start-sleep -m 3000@(@($ie.document.getElementsByTagName("frameset"))[0].getElementsByTagName("frame"))[0].src@(@($ie.document.getElementsByTagName("frameset"))[0].getElementsByTagName("frame"))[1].src##################################################################
This topic is 15 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked