Bert Posted November 20, 2007 Share Posted November 20, 2007 I have a webpage that has a collection of hyperlinks. I need to get the list of links. To do that, I started with this, and it will display them in the console: (code found doing a search in the forum) (thanks Dale!) $oLinks = _IELinkGetCollection ($oIE) $iNumLinks = @extended For $oLink in $oLinks ConsoleWrite(_IEPropertyGet($oLink, "innertext") & @CR) Next The report to the console is this, which is what I want to put into the array: 0 Name of home page Help 00630383 00630442 00631654 00632038 00627526 00632520 00630998 00630363 00618712 00631318 http://xxxxxx/xxxxxxx 00599640 00621858 00630371 00618672 00627293 - 0002 00627308 - 0009 00629003 - 0001 00618672 - 0003 00621184 - 0002 00621184 - 0003 00621184 - 0004 00621184 - 0001 00627308-0005 - sub1 My question is, how do I get this list in a array? I tried this: $d = _IEPropertyGet($oLink, "innertext") $arr = StringSplit($d & @CR, @CR) It reports 3 items, and the only one in the array that has what I want is the last one. Currently the webpage has over 20 links in it, and I need to get the ones that meet a certain criteria (Text name only has numbers in it, no letters) The amount of links is NOT a constant (changes at the drop of a hat), so I was trying to first get the collection, then put that list into a array. How do I get what is being put to the console into a array? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Nahuel Posted November 20, 2007 Share Posted November 20, 2007 I suppose you could declare an array at the top of the script and then just do this: For $oLink in $oLinks ConsoleWrite(_IEPropertyGet($oLink, "innertext") & @CR) _ArrayAdd($Array,_IEPropertyGet($oLink, "innertext") ) Next Link to comment Share on other sites More sharing options...
Bert Posted November 20, 2007 Author Share Posted November 20, 2007 Perfect! thanks! The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted November 20, 2007 Author Share Posted November 20, 2007 Second question along the same lines - I'm making a webpage using autoit that will make a series of frames, and open the list I got. Can I get a example of getting a link collection from one page (3 links), then having each link be opened in a frame in a new page? I have this, but it doesn't work: dim $s_html $s_html &= "<HTML>" & @CR $s_html &= "<HEAD>" & @CR $s_html &= "<TITLE>Service Request My Documents Expanded Report</TITLE>" & @CR $s_html &= "<STYLE>body {font-family: Arial}</STYLE>" & @CR $s_html &= "</HEAD>" & @CR $s_html &= "<frameset rows='100%,100,100%'>"& @CR $s_html &= "<frame name='1' src='about:blank' scrolling='yes'>"& @CR $s_html &= "<frame name='2' src='about:blank' scrolling='yes'>"& @CR $s_html &= "<frame name='3' src='about:blank' scrolling='yes'>"& @CR $s_html &= "<noframes>" & @CR $s_html &= "<BODY>" & @CR $s_html &= "</HTML>" & @CR $s_html &="</noframes>" & @CR $s_html &="</frameset>" & @CR $s_html &= "</BODY>" $ff = _IECreate("about:blank", 0) _IEDocWriteHTML($ff, $s_html) $oLinks = _IELinkGetCollection($oIE) $p = 0 do for $oLink in $oLinks $sMyString = $Array[$p] $sLinkText = _IEPropertyGet($oLink, "innerText") If StringInStr($sLinkText, $sMyString) Then $oFrame = _IEFrameGetObjByName ($ff, "1") _IENavigate($oFrame, $oLink.href) ExitLoop EndIf $l = $l +1 next until $l = 1 The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
DaleHohm Posted November 20, 2007 Share Posted November 20, 2007 And "doesn't work" means what exactly? (see my sig) Also, I can't run your code due to missing variables. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Bert Posted November 20, 2007 Author Share Posted November 20, 2007 I'm closer to getting what I want. The only trouble I'm having now is 2 things: 1. I need to navigate the first frame I have made to the first item in my $links array 2. I need to come up with a method to make a number of frames depended on the number of links. If there are 4 links for example, then I will have 4 frames. Currently, I have 3 frames being made for testing. expandcollapse popup#include <IE.au3> #include <Array.au3> ;opens the page $oIE = _IECreate("http://xxxxxxxxxxxxxxxxxxxxxxxxxx", 0, 1) $oLinks = _IELinkGetCollection($oIE) Global $Array[1], $links[1], $editlist[1] $sMyString = "Log In" For $oLink in $oLinks $sLinkText = _IEPropertyGet($oLink, "innerText") If StringInStr($sLinkText, $sMyString) Then _IEAction($oLink, "click") ExitLoop EndIf Next $oLinks = _IELinkGetCollection ($oIE) $iNumLinks = @extended For $oLink In $oLinks _ArrayAdd($Array,_IEPropertyGet($oLink, "innertext") ) _ArrayAdd($links, $oLink.href) Next _ArrayDelete($Array,0) _ArrayDelete($Array,0) _ArrayDelete($Array,0) _ArrayDelete($Array,0) _ArrayDelete($links,0) _ArrayDelete($links,0) _ArrayDelete($links,0) _ArrayDelete($links,0) ;got list of links from page with names to edit with. No need to change code from this point up. $iMax = UBound($array) $iMax1 = UBound($links) $p = 0 Do $str = StringIsDigit($Array[$p]) $siS = StringInStr($Array[$p], "http:") $siS1 = StringInStr($Array[$p], " - ") if $str = 1 then $p = $p +1 Elseif $siS = 1 then _ArrayDelete($Array,$p) _ArrayDelete($links,$p) $iMax = UBound($array) $iMax1 = UBound($links) Else if $siS1 > 1 then $p = $p +1 Endif endif $iMax = UBound($array) $iMax1 = UBound($links) until $p = $iMax dim $s_html $s_html &= '<HTML>' & @CR $s_html &= '<HEAD>' & @CR $s_html &= '<TITLE>Service Request My Documents Expanded Report</TITLE>' & @CR $s_html &= '<STYLE>body {font-family: Arial}</STYLE>' & @CR $s_html &= '</HEAD>' & @CR $s_html &= '<frameset rows="100%,100,100%">'& @CR $s_html &= '<frame name="1" src="about:blank" scrolling="yes">'& @CR $s_html &= '<frame name="2" src="about:blank" scrolling="yes">'& @CR $s_html &= '<frame name="3" src="about:blank" scrolling="yes">'& @CR $s_html &= '<noframes>' & @CR $s_html &= '<BODY>' & @CR $s_html &= '</HTML>' & @CR $s_html &= '</noframes>' & @CR $s_html &= '</frameset>' & @CR $s_html &= '</BODY>' $ff = _IECreate("about:blank", 0) _IEDocWriteHTML($ff, $s_html) $nnn = _IEGetObjByName ($oIE, $Array[1]) $oFrame = _IEFrameGetObjByName ($ff, "1") _IENavigate($oFrame,$links[1]) The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted November 20, 2007 Author Share Posted November 20, 2007 I figured out I needed to do a refresh to $ff after I write the html to get it to work. I'm still having trouble getting the frames to be the correct size. They keep sizing themselfs to the size of the screen in that I want to have the webpage be split so that I have a fill page per frame. If I try for 3 frames for example, it splits the viewing area into 3 secions, but does not resize the page to make it 3 times as big. I hope I'm explaining this right The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted November 21, 2007 Author Share Posted November 21, 2007 switched to tables with a array design. Seems to do what I want. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now