![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | REQ: internetexplorer com object and access to array of links I use the next script to extract all links from a website: param($url = $(throw "Please specify a URL")) $ie=new-object -com internetexplorer.application; $ie.navigate2($url); while ($ie.busy) {sleep -milliseconds 50} $links=@($ie.document.getElementsByTagName("A")); $links | select href $ie.quit(); It displays all links ....but i need access to each separate link in $links. So i tried this: ForEach ($link in $links) {#Do myThing} But it returns : "System.__ComObject" instead of a link. IMO $links is a array of links, so way can't access the separate links ? Please help Thanks in advance, Robertico |
My System Specs![]() |
| | #2 (permalink) |
| | Re: REQ: internetexplorer com object and access to array of links Hi Robertico, Try to select the properties you need first and then access the array: PS 55> $ie=new-object -com internetexplorer.application PS 56> $ie.visible=$true PS 57> $ie.navigate2("www.google.com") PS 58> while ($ie.busy) {sleep -milliseconds 50} PS 59> $links=@($ie.document.getElementsByTagName("A")) | select href,innerText PS 60> $ie.quit() PS 61> PS 61> $links href innerText ---- --------- http://images.google.co.il/imghp?hl=en&tab=wi Images http://news.google.co.il/nwshp?hl=en&tab=wn News http://groups.google.co.il/grphp?hl=en&tab=wg Groups http://scholar.google.com/schhp?hl=en&tab=ws Scholar http://mail.google.com/mail/?hl=en&tab=wm Gmail http://www.google.co.il/intl/en/options/ more ? http://www.google.com/calendar/render?hl=en&tab=wc Calendar http://docs.google.com/?hl=en&tab=wo Documents http://www.google.co.il/intl/en/options/ even more » https://www.google.com/accounts/Logi...//www.google.c... Sign in http://www.google.co.il/advanced_search?hl=en Advanced Search http://www.google.co.il/preferences?hl=en Preferences http://www.google.co.il/language_tools?hl=en Language Tools http://www.google.co.il/setprefs?sig...E6FxggehvupU4k... ????? http://www.google.co.il/intl/en/ads/ Advertising Program http://www.google.co.il/intl/en/about.html About http://www.google.com/ncr Go to Google.com PS 62> $links.length 17 # get the first link PS 63> $links[0] href innerText ---- --------- http://images.google.co.il/imghp?hl=en&tab=wi Images # get the last link PS 64> $links[-1] href innerText ---- --------- http://www.google.com/ncr Go to Google.com Go to Google.com ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I use the next script to extract all links from a website: > > param($url = $(throw "Please specify a URL")) > $ie=new-object -com internetexplorer.application; > $ie.navigate2($url); > while ($ie.busy) {sleep -milliseconds 50} > $links=@($ie.document.getElementsByTagName("A")); > $links | select href > $ie.quit(); > It displays all links ....but i need access to each separate link in > $links. > > So i tried this: > ForEach ($link in $links) > {#Do myThing} > But it returns : "System.__ComObject" instead of a link. > > IMO $links is a array of links, so way can't access the separate links > ? > > Please help > > Thanks in advance, > > Robertico > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: REQ: internetexplorer com object and access to array of links IShay, 'll tested it. (I only need the links, so i deleted the innerText from the selection) the variable $links in your example displays all the links (as expected) $links[0] displays: @{href=http://images.google.nl/imghp?hl=nl&tab=wi} So, why displays $links all the links without @{href= } and $links[0] with @{href= } Robertico "Shay Levi" <no@xxxxxx> wrote in message news:8766a944292af8ca7756466a7250@xxxxxx Quote: > > Hi Robertico, > > > Try to select the properties you need first and then access the array: > > > PS 55> $ie=new-object -com internetexplorer.application > PS 56> $ie.visible=$true > PS 57> $ie.navigate2("www.google.com") > PS 58> while ($ie.busy) {sleep -milliseconds 50} > PS 59> $links=@($ie.document.getElementsByTagName("A")) | select > href,innerText > PS 60> $ie.quit() > PS 61> > PS 61> $links > > href > innerText > ---- --------- > http://images.google.co.il/imghp?hl=en&tab=wi > Images > http://news.google.co.il/nwshp?hl=en&tab=wn News > http://groups.google.co.il/grphp?hl=en&tab=wg > Groups > http://scholar.google.com/schhp?hl=en&tab=ws > Scholar > http://mail.google.com/mail/?hl=en&tab=wm > Gmail > http://www.google.co.il/intl/en/options/ more > ? > http://www.google.com/calendar/render?hl=en&tab=wc > Calendar > http://docs.google.com/?hl=en&tab=wo > Documents > http://www.google.co.il/intl/en/options/ even > more » > https://www.google.com/accounts/Logi...//www.google.c... Sign > in > http://www.google.co.il/advanced_search?hl=en > Advanced Search > http://www.google.co.il/preferences?hl=en > Preferences > http://www.google.co.il/language_tools?hl=en > Language Tools > http://www.google.co.il/setprefs?sig...E6FxggehvupU4k... > ????? > http://www.google.co.il/intl/en/ads/ > Advertising Program > http://www.google.co.il/intl/en/about.html > About Google > http://www.google.com/ncr Go > to Google.com > > > PS 62> $links.length > 17 > > # get the first link > PS 63> $links[0] > > href > innerText > ---- --------- > http://images.google.co.il/imghp?hl=en&tab=wi > Images > > > # get the last link > PS 64> $links[-1] > > href > innerText > ---- --------- > http://www.google.com/ncr Go > to Google.com > > Go to Google.com > > > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: >> I use the next script to extract all links from a website: >> >> param($url = $(throw "Please specify a URL")) >> $ie=new-object -com internetexplorer.application; >> $ie.navigate2($url); >> while ($ie.busy) {sleep -milliseconds 50} >> $links=@($ie.document.getElementsByTagName("A")); >> $links | select href >> $ie.quit(); >> It displays all links ....but i need access to each separate link in >> $links. >> >> So i tried this: >> ForEach ($link in $links) >> {#Do myThing} >> But it returns : "System.__ComObject" instead of a link. >> >> IMO $links is a array of links, so way can't access the separate links >> ? >> >> Please help >> >> Thanks in advance, >> >> Robertico >> > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: REQ: internetexplorer com object and access to array of links Hi I'm not sure I follow you. If I execute $links[0] (deleted the innerText) I get: PS 29> $links[0] href ---- http://images.google.co.il/imghp?hl=en&tab=wi PS 30> $links[0].href http://images.google.co.il/imghp?hl=en&tab=wi Nothing like this: @{href=http://images.google.nl/imghp?hl=nl&tab=wi} ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > IShay, > > 'll tested it. > (I only need the links, so i deleted the innerText from the selection) > the variable $links in your example displays all the links (as > expected) $links[0] displays: > @{href=http://images.google.nl/imghp?hl=nl&tab=wi} > > So, why displays $links all the links without @{href= } and > $links[0] with @{href= } > > Robertico > > "Shay Levi" <no@xxxxxx> wrote in message > news:8766a944292af8ca7756466a7250@xxxxxx > Quote: >> Hi Robertico, >> >> Try to select the properties you need first and then access the >> array: >> >> PS 55> $ie=new-object -com internetexplorer.application >> PS 56> $ie.visible=$true >> PS 57> $ie.navigate2("www.google.com") >> PS 58> while ($ie.busy) {sleep -milliseconds 50} >> PS 59> $links=@($ie.document.getElementsByTagName("A")) | select >> href,innerText >> PS 60> $ie.quit() >> PS 61> >> PS 61> $links >> href >> innerText >> ---- >> --------- >> http://images.google.co.il/imghp?hl=en&tab=wi >> Images >> http://news.google.co.il/nwshp?hl=en&tab=wn >> News >> http://groups.google.co.il/grphp?hl=en&tab=wg >> Groups >> http://scholar.google.com/schhp?hl=en&tab=ws >> Scholar >> http://mail.google.com/mail/?hl=en&tab=wm >> Gmail >> http://www.google.co.il/intl/en/options/ >> more >> ? >> http://www.google.com/calendar/render?hl=en&tab=wc >> Calendar >> http://docs.google.com/?hl=en&tab=wo >> Documents >> http://www.google.co.il/intl/en/options/ >> even >> more » >> https://www.google.com/accounts/Logi...//www.google.c... >> Sign >> in >> http://www.google.co.il/advanced_search?hl=en >> Advanced Search >> http://www.google.co.il/preferences?hl=en >> Preferences >> http://www.google.co.il/language_tools?hl=en >> Language Tools >> http://www.google.co.il/setprefs?sig...E6FxggehvupU4k... >> ????? >> http://www.google.co.il/intl/en/ads/ >> Advertising Program >> http://www.google.co.il/intl/en/about.html >> About Google >> http://www.google.com/ncr >> Go >> to Google.com >> PS 62> $links.length >> 17 >> # get the first link >> PS 63> $links[0] >> href >> innerText >> ---- >> --------- >> http://images.google.co.il/imghp?hl=en&tab=wi >> Images >> # get the last link >> PS 64> $links[-1] >> href >> innerText >> ---- >> --------- >> http://www.google.com/ncr >> Go >> to Google.com >> Go to Google.com >> >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> I use the next script to extract all links from a website: >>> >>> param($url = $(throw "Please specify a URL")) >>> $ie=new-object -com internetexplorer.application; >>> $ie.navigate2($url); >>> while ($ie.busy) {sleep -milliseconds 50} >>> $links=@($ie.document.getElementsByTagName("A")); >>> $links | select href >>> $ie.quit(); >>> It displays all links ....but i need access to each separate link in >>> $links. >>> So i tried this: >>> ForEach ($link in $links) >>> {#Do myThing} >>> But it returns : "System.__ComObject" instead of a link. >>> IMO $links is a array of links, so way can't access the separate >>> links ? >>> >>> Please help >>> >>> Thanks in advance, >>> >>> Robertico >>> |
My System Specs![]() |
| | #5 (permalink) |
| | Re: REQ: internetexplorer com object and access to array of links The complete script: $url=www.google.com $ie=new-object -com internetexplorer.application; $ie.navigate2($url); while ($ie.busy) {sleep -milliseconds 50} $links=@($ie.document.getElementsByTagName("A"))| select href $ie.quit(); Write-Host $links[0] Screendump: Command line PowerGUI Robertico "Shay Levi" <no@xxxxxx> wrote in message news:8766a944297f48ca78c8322783be@xxxxxx Quote: > > > Hi > > I'm not sure I follow you. If I execute $links[0] (deleted the innerText) > I get: > > > PS 29> $links[0] > > href > ---- > http://images.google.co.il/imghp?hl=en&tab=wi > > > PS 30> $links[0].href > http://images.google.co.il/imghp?hl=en&tab=wi > > > > Nothing like this: > > @{href=http://images.google.nl/imghp?hl=nl&tab=wi} > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: >> IShay, >> >> 'll tested it. >> (I only need the links, so i deleted the innerText from the selection) >> the variable $links in your example displays all the links (as >> expected) $links[0] displays: >> @{href=http://images.google.nl/imghp?hl=nl&tab=wi} >> >> So, why displays $links all the links without @{href= } and >> $links[0] with @{href= } >> >> Robertico >> >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a944292af8ca7756466a7250@xxxxxx >> Quote: >>> Hi Robertico, >>> >>> Try to select the properties you need first and then access the >>> array: >>> >>> PS 55> $ie=new-object -com internetexplorer.application >>> PS 56> $ie.visible=$true >>> PS 57> $ie.navigate2("www.google.com") >>> PS 58> while ($ie.busy) {sleep -milliseconds 50} >>> PS 59> $links=@($ie.document.getElementsByTagName("A")) | select >>> href,innerText >>> PS 60> $ie.quit() >>> PS 61> >>> PS 61> $links >>> href >>> innerText >>> ---- >>> --------- >>> http://images.google.co.il/imghp?hl=en&tab=wi >>> Images >>> http://news.google.co.il/nwshp?hl=en&tab=wn >>> News >>> http://groups.google.co.il/grphp?hl=en&tab=wg >>> Groups >>> http://scholar.google.com/schhp?hl=en&tab=ws >>> Scholar >>> http://mail.google.com/mail/?hl=en&tab=wm >>> Gmail >>> http://www.google.co.il/intl/en/options/ >>> more >>> ? >>> http://www.google.com/calendar/render?hl=en&tab=wc >>> Calendar >>> http://docs.google.com/?hl=en&tab=wo >>> Documents >>> http://www.google.co.il/intl/en/options/ >>> even >>> more » >>> https://www.google.com/accounts/Logi...//www.google.c... >>> Sign >>> in >>> http://www.google.co.il/advanced_search?hl=en >>> Advanced Search >>> http://www.google.co.il/preferences?hl=en >>> Preferences >>> http://www.google.co.il/language_tools?hl=en >>> Language Tools >>> http://www.google.co.il/setprefs?sig...E6FxggehvupU4k... >>> ????? >>> http://www.google.co.il/intl/en/ads/ >>> Advertising Program >>> http://www.google.co.il/intl/en/about.html >>> About Google >>> http://www.google.com/ncr >>> Go >>> to Google.com >>> PS 62> $links.length >>> 17 >>> # get the first link >>> PS 63> $links[0] >>> href >>> innerText >>> ---- >>> --------- >>> http://images.google.co.il/imghp?hl=en&tab=wi >>> Images >>> # get the last link >>> PS 64> $links[-1] >>> href >>> innerText >>> ---- >>> --------- >>> http://www.google.com/ncr >>> Go >>> to Google.com >>> Go to Google.com >>> >>> ----- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>>> I use the next script to extract all links from a website: >>>> >>>> param($url = $(throw "Please specify a URL")) >>>> $ie=new-object -com internetexplorer.application; >>>> $ie.navigate2($url); >>>> while ($ie.busy) {sleep -milliseconds 50} >>>> $links=@($ie.document.getElementsByTagName("A")); >>>> $links | select href >>>> $ie.quit(); >>>> It displays all links ....but i need access to each separate link in >>>> $links. >>>> So i tried this: >>>> ForEach ($link in $links) >>>> {#Do myThing} >>>> But it returns : "System.__ComObject" instead of a link. >>>> IMO $links is a array of links, so way can't access the separate >>>> links ? >>>> >>>> Please help >>>> >>>> Thanks in advance, >>>> >>>> Robertico >>>> > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: REQ: internetexplorer com object and access to array of links In addition. I'am using Powershell v.1.0 Robertico "Shay Levi" <no@xxxxxx> wrote in message news:8766a944297f48ca78c8322783be@xxxxxx Quote: > > > Hi > > I'm not sure I follow you. If I execute $links[0] (deleted the innerText) > I get: > > > PS 29> $links[0] > > href > ---- > http://images.google.co.il/imghp?hl=en&tab=wi > > > PS 30> $links[0].href > http://images.google.co.il/imghp?hl=en&tab=wi > > > > Nothing like this: > > @{href=http://images.google.nl/imghp?hl=nl&tab=wi} > > > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: >> IShay, >> >> 'll tested it. >> (I only need the links, so i deleted the innerText from the selection) >> the variable $links in your example displays all the links (as >> expected) $links[0] displays: >> @{href=http://images.google.nl/imghp?hl=nl&tab=wi} >> >> So, why displays $links all the links without @{href= } and >> $links[0] with @{href= } >> >> Robertico >> >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a944292af8ca7756466a7250@xxxxxx >> Quote: >>> Hi Robertico, >>> >>> Try to select the properties you need first and then access the >>> array: >>> >>> PS 55> $ie=new-object -com internetexplorer.application >>> PS 56> $ie.visible=$true >>> PS 57> $ie.navigate2("www.google.com") >>> PS 58> while ($ie.busy) {sleep -milliseconds 50} >>> PS 59> $links=@($ie.document.getElementsByTagName("A")) | select >>> href,innerText >>> PS 60> $ie.quit() >>> PS 61> >>> PS 61> $links >>> href >>> innerText >>> ---- >>> --------- >>> http://images.google.co.il/imghp?hl=en&tab=wi >>> Images >>> http://news.google.co.il/nwshp?hl=en&tab=wn >>> News >>> http://groups.google.co.il/grphp?hl=en&tab=wg >>> Groups >>> http://scholar.google.com/schhp?hl=en&tab=ws >>> Scholar >>> http://mail.google.com/mail/?hl=en&tab=wm >>> Gmail >>> http://www.google.co.il/intl/en/options/ >>> more >>> ? >>> http://www.google.com/calendar/render?hl=en&tab=wc >>> Calendar >>> http://docs.google.com/?hl=en&tab=wo >>> Documents >>> http://www.google.co.il/intl/en/options/ >>> even >>> more » >>> https://www.google.com/accounts/Logi...//www.google.c... >>> Sign >>> in >>> http://www.google.co.il/advanced_search?hl=en >>> Advanced Search >>> http://www.google.co.il/preferences?hl=en >>> Preferences >>> http://www.google.co.il/language_tools?hl=en >>> Language Tools >>> http://www.google.co.il/setprefs?sig...E6FxggehvupU4k... >>> ????? >>> http://www.google.co.il/intl/en/ads/ >>> Advertising Program >>> http://www.google.co.il/intl/en/about.html >>> About Google >>> http://www.google.com/ncr >>> Go >>> to Google.com >>> PS 62> $links.length >>> 17 >>> # get the first link >>> PS 63> $links[0] >>> href >>> innerText >>> ---- >>> --------- >>> http://images.google.co.il/imghp?hl=en&tab=wi >>> Images >>> # get the last link >>> PS 64> $links[-1] >>> href >>> innerText >>> ---- >>> --------- >>> http://www.google.com/ncr >>> Go >>> to Google.com >>> Go to Google.com >>> >>> ----- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>>> I use the next script to extract all links from a website: >>>> >>>> param($url = $(throw "Please specify a URL")) >>>> $ie=new-object -com internetexplorer.application; >>>> $ie.navigate2($url); >>>> while ($ie.busy) {sleep -milliseconds 50} >>>> $links=@($ie.document.getElementsByTagName("A")); >>>> $links | select href >>>> $ie.quit(); >>>> It displays all links ....but i need access to each separate link in >>>> $links. >>>> So i tried this: >>>> ForEach ($link in $links) >>>> {#Do myThing} >>>> But it returns : "System.__ComObject" instead of a link. >>>> IMO $links is a array of links, so way can't access the separate >>>> links ? >>>> >>>> Please help >>>> >>>> Thanks in advance, >>>> >>>> Robertico >>>> > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: REQ: internetexplorer com object and access to array of links I guess that's the reason, I'm using v2. I don't see it as a problem but If you want $links[0] to look like a plain string then replace select with foreach: PS > $links=@($ie.document.getElementsByTagName("A"))| % {$_.href} PS > $links[0] http://images.google.co.il/imghp?hl=iw&tab=wi ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > In addition. > > I'am using Powershell v.1.0 > > Robertico > > "Shay Levi" <no@xxxxxx> wrote in message > news:8766a944297f48ca78c8322783be@xxxxxx > Quote: >> Hi >> >> I'm not sure I follow you. If I execute $links[0] (deleted the >> innerText) I get: >> >> PS 29> $links[0] >> >> href >> ---- >> http://images.google.co.il/imghp?hl=en&tab=wi >> PS 30> $links[0].href >> http://images.google.co.il/imghp?hl=en&tab=wi >> Nothing like this: >> >> @{href=http://images.google.nl/imghp?hl=nl&tab=wi} >> >> ----- >> Shay Levi >> $cript Fanatic >> http://scriptolog.blogspot.com Quote: >>> IShay, >>> >>> 'll tested it. >>> (I only need the links, so i deleted the innerText from the >>> selection) >>> the variable $links in your example displays all the links (as >>> expected) $links[0] displays: >>> @{href=http://images.google.nl/imghp?hl=nl&tab=wi} >>> So, why displays $links all the links without @{href= } and >>> $links[0] with @{href= } >>> >>> Robertico >>> >>> "Shay Levi" <no@xxxxxx> wrote in message >>> news:8766a944292af8ca7756466a7250@xxxxxx >>>> Hi Robertico, >>>> >>>> Try to select the properties you need first and then access the >>>> array: >>>> >>>> PS 55> $ie=new-object -com internetexplorer.application >>>> PS 56> $ie.visible=$true >>>> PS 57> $ie.navigate2("www.google.com") >>>> PS 58> while ($ie.busy) {sleep -milliseconds 50} >>>> PS 59> $links=@($ie.document.getElementsByTagName("A")) | select >>>> href,innerText >>>> PS 60> $ie.quit() >>>> PS 61> >>>> PS 61> $links >>>> href >>>> innerText >>>> ---- >>>> --------- >>>> http://images.google.co.il/imghp?hl=en&tab=wi >>>> Images >>>> http://news.google.co.il/nwshp?hl=en&tab=wn >>>> News >>>> http://groups.google.co.il/grphp?hl=en&tab=wg >>>> Groups >>>> http://scholar.google.com/schhp?hl=en&tab=ws >>>> Scholar >>>> http://mail.google.com/mail/?hl=en&tab=wm >>>> Gmail >>>> http://www.google.co.il/intl/en/options/ >>>> more >>>> ? >>>> http://www.google.com/calendar/render?hl=en&tab=wc >>>> Calendar >>>> http://docs.google.com/?hl=en&tab=wo >>>> Documents >>>> http://www.google.co.il/intl/en/options/ >>>> even >>>> more » >>>> https://www.google.com/accounts/Logi...//www.google.c. >>>> .. >>>> Sign >>>> in >>>> http://www.google.co.il/advanced_search?hl=en >>>> Advanced Search >>>> http://www.google.co.il/preferences?hl=en >>>> Preferences >>>> http://www.google.co.il/language_tools?hl=en >>>> Language Tools >>>> http://www.google.co.il/setprefs?sig...E6FxggehvupU4k. >>>> .. >>>> ????? >>>> http://www.google.co.il/intl/en/ads/ >>>> Advertising Program >>>> http://www.google.co.il/intl/en/about.html >>>> About Google >>>> http://www.google.com/ncr >>>> Go >>>> to Google.com >>>> PS 62> $links.length >>>> 17 >>>> # get the first link >>>> PS 63> $links[0] >>>> href >>>> innerText >>>> ---- >>>> --------- >>>> http://images.google.co.il/imghp?hl=en&tab=wi >>>> Images >>>> # get the last link >>>> PS 64> $links[-1] >>>> href >>>> innerText >>>> ---- >>>> --------- >>>> http://www.google.com/ncr >>>> Go >>>> to Google.com >>>> Go to Google.com >>>> ----- >>>> Shay Levi >>>> $cript Fanatic >>>> http://scriptolog.blogspot.com >>>>> I use the next script to extract all links from a website: >>>>> >>>>> param($url = $(throw "Please specify a URL")) >>>>> $ie=new-object -com internetexplorer.application; >>>>> $ie.navigate2($url); >>>>> while ($ie.busy) {sleep -milliseconds 50} >>>>> $links=@($ie.document.getElementsByTagName("A")); >>>>> $links | select href >>>>> $ie.quit(); >>>>> It displays all links ....but i need access to each separate link >>>>> in >>>>> $links. >>>>> So i tried this: >>>>> ForEach ($link in $links) >>>>> {#Do myThing} >>>>> But it returns : "System.__ComObject" instead of a link. >>>>> IMO $links is a array of links, so way can't access the separate >>>>> links ? >>>>> Please help >>>>> >>>>> Thanks in advance, >>>>> >>>>> Robertico >>>>> |
My System Specs![]() |
| | #8 (permalink) |
| | Re: REQ: internetexplorer com object and access to array of links Shay, Thanks ! $links=@($ie.document.getElementsByTagName("A"))| % {$_.href} did the trick !! BTW i upgraded to version 2 CTP Robertico "Shay Levi" <no@xxxxxx> wrote in message news:8766a9442996e8ca792d568fa15e@xxxxxx Quote: > > I guess that's the reason, I'm using v2. I don't see it as a problem but > If you want $links[0] to look like a plain string then replace select with > foreach: > > > PS > $links=@($ie.document.getElementsByTagName("A"))| % {$_.href} > PS > $links[0] > > http://images.google.co.il/imghp?hl=iw&tab=wi > > ----- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: >> In addition. >> >> I'am using Powershell v.1.0 >> >> Robertico >> >> "Shay Levi" <no@xxxxxx> wrote in message >> news:8766a944297f48ca78c8322783be@xxxxxx >> Quote: >>> Hi >>> >>> I'm not sure I follow you. If I execute $links[0] (deleted the >>> innerText) I get: >>> >>> PS 29> $links[0] >>> >>> href >>> ---- >>> http://images.google.co.il/imghp?hl=en&tab=wi >>> PS 30> $links[0].href >>> http://images.google.co.il/imghp?hl=en&tab=wi >>> Nothing like this: >>> >>> @{href=http://images.google.nl/imghp?hl=nl&tab=wi} >>> >>> ----- >>> Shay Levi >>> $cript Fanatic >>> http://scriptolog.blogspot.com >>>> IShay, >>>> >>>> 'll tested it. >>>> (I only need the links, so i deleted the innerText from the >>>> selection) >>>> the variable $links in your example displays all the links (as >>>> expected) $links[0] displays: >>>> @{href=http://images.google.nl/imghp?hl=nl&tab=wi} >>>> So, why displays $links all the links without @{href= } and >>>> $links[0] with @{href= } >>>> >>>> Robertico >>>> >>>> "Shay Levi" <no@xxxxxx> wrote in message >>>> news:8766a944292af8ca7756466a7250@xxxxxx >>>>> Hi Robertico, >>>>> >>>>> Try to select the properties you need first and then access the >>>>> array: >>>>> >>>>> PS 55> $ie=new-object -com internetexplorer.application >>>>> PS 56> $ie.visible=$true >>>>> PS 57> $ie.navigate2("www.google.com") >>>>> PS 58> while ($ie.busy) {sleep -milliseconds 50} >>>>> PS 59> $links=@($ie.document.getElementsByTagName("A")) | select >>>>> href,innerText >>>>> PS 60> $ie.quit() >>>>> PS 61> >>>>> PS 61> $links >>>>> href >>>>> innerText >>>>> ---- >>>>> --------- >>>>> http://images.google.co.il/imghp?hl=en&tab=wi >>>>> Images >>>>> http://news.google.co.il/nwshp?hl=en&tab=wn >>>>> News >>>>> http://groups.google.co.il/grphp?hl=en&tab=wg >>>>> Groups >>>>> http://scholar.google.com/schhp?hl=en&tab=ws >>>>> Scholar >>>>> http://mail.google.com/mail/?hl=en&tab=wm >>>>> Gmail >>>>> http://www.google.co.il/intl/en/options/ >>>>> more >>>>> ? >>>>> http://www.google.com/calendar/render?hl=en&tab=wc >>>>> Calendar >>>>> http://docs.google.com/?hl=en&tab=wo >>>>> Documents >>>>> http://www.google.co.il/intl/en/options/ >>>>> even >>>>> more » >>>>> https://www.google.com/accounts/Logi...//www.google.c. >>>>> .. >>>>> Sign >>>>> in >>>>> http://www.google.co.il/advanced_search?hl=en >>>>> Advanced Search >>>>> http://www.google.co.il/preferences?hl=en >>>>> Preferences >>>>> http://www.google.co.il/language_tools?hl=en >>>>> Language Tools >>>>> http://www.google.co.il/setprefs?sig...E6FxggehvupU4k. >>>>> .. >>>>> ????? >>>>> http://www.google.co.il/intl/en/ads/ >>>>> Advertising Program >>>>> http://www.google.co.il/intl/en/about.html >>>>> About Google >>>>> http://www.google.com/ncr >>>>> Go >>>>> to Google.com >>>>> PS 62> $links.length >>>>> 17 >>>>> # get the first link >>>>> PS 63> $links[0] >>>>> href >>>>> innerText >>>>> ---- >>>>> --------- >>>>> http://images.google.co.il/imghp?hl=en&tab=wi >>>>> Images >>>>> # get the last link >>>>> PS 64> $links[-1] >>>>> href >>>>> innerText >>>>> ---- >>>>> --------- >>>>> http://www.google.com/ncr >>>>> Go >>>>> to Google.com >>>>> Go to Google.com >>>>> ----- >>>>> Shay Levi >>>>> $cript Fanatic >>>>> http://scriptolog.blogspot.com >>>>>> I use the next script to extract all links from a website: >>>>>> >>>>>> param($url = $(throw "Please specify a URL")) >>>>>> $ie=new-object -com internetexplorer.application; >>>>>> $ie.navigate2($url); >>>>>> while ($ie.busy) {sleep -milliseconds 50} >>>>>> $links=@($ie.document.getElementsByTagName("A")); >>>>>> $links | select href >>>>>> $ie.quit(); >>>>>> It displays all links ....but i need access to each separate link >>>>>> in >>>>>> $links. >>>>>> So i tried this: >>>>>> ForEach ($link in $links) >>>>>> {#Do myThing} >>>>>> But it returns : "System.__ComObject" instead of a link. >>>>>> IMO $links is a array of links, so way can't access the separate >>>>>> links ? >>>>>> Please help >>>>>> >>>>>> Thanks in advance, >>>>>> >>>>>> Robertico >>>>>> > |
My System Specs![]() |
| | #9 (permalink) |
| | Oana ciau |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| InternetExplorer Com Object Find Utility | PowerShell | |||
| Give focus to an InternetExplorer.Application object | VB Script | |||
| Re: InternetExplorer.Application COM object. | PowerShell | |||
| InternetExplorer.Application COM object. | PowerShell | |||
| new-object -com internetexplorer.application | PowerShell | |||