![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Arraylist object to string Nested query doesn't work. So I type $al = getSites("http://seattle.craigslist.org/bik"); then $al | %{getSites($_)} which spews a bunch of errors. Any ideas? Thanks! function getSites($url){ Write-Host $url $arraylist = new-Object System.Collections.ArrayList #$url = "http://seattle.craigslist.org/bik" $xHTTP = new-object -com msxml2.xmlhttp; $xHTTP.open("GET",$url,$false); $xHTTP.send(); $webpage = $xHTTP.ResponseText; # returns the html doc $re = [regex]'<\s*a\s+href\s*=\s*(?<path>"[^"]*")' $re.Matches($webpage) | %{ Write-Host $_.groups['path'].value [void]$arraylist.Add($_.groups['path'].value) } return $arraylist } |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: Arraylist object to string Try this $url="http://seattle.craigslist.org/bik/"; $webpage=(new-object net.webclient).DownloadString($url); $re = [regex]'<\s*a\s+href\s*=\s*(?<path>"[^"]*")' $re.Matches($wc) | % {$_.groups['path'].value} "http://www.craigslist.org/about/help/" "https://post.craigslist.org/sea/S" "/" "/bik/" "/see/bik/" "/est/bik/" "/sno/bik/" "/kit/bik/" "/tac/bik/" "/oly/bik/" "/skc/bik/" "http://forums.seattle.craigslist.org/?forumID=95" (..) personally, I find this less painfull ![]() $url="http://seattle.craigslist.org/bik/"; $ie=new-object -com internetexplorer.application; $ie.visible=$true $ie.navigate2($url); while ($ie.busy) {sleep -milliseconds 50} $links=@($ie.document.getElementsByTagName("A")); $links | select href,innerText $ie.Quit(); href innerText ---- --------- http://www.craigslist.org/about/help/ help https://post.craigslist.org/sea/S post http://seattle.craigslist.org/ seattle-tacoma craigslist http://seattle.craigslist.org/bik/ bicycles http://seattle.craigslist.org/see/bik/ seattle http://seattle.craigslist.org/est/bik/ eastside http://seattle.craigslist.org/sno/bik/ snohomish co http://seattle.craigslist.org/kit/bik/ kitsap co http://seattle.craigslist.org/tac/bik/ tacoma (...) Shay http://scriptolog.blogspot.com
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: Arraylist object to string Had a typo in the first example, this one works $url="http://seattle.craigslist.org/bik/"; $webpage=(new-object net.webclient).DownloadString($url); $re = [regex]'<\s*a\s+href\s*=\s*(?<path>"[^"]*")' $re.Matches($webpage) | % {$_.groups['path'].value} Shay http://scriptolog.blogspot.com
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Thread-safety: Change property of items in arraylist versus removingitems from the arraylist | Curious | .NET General | 2 | 08-06-2008 06:36 AM |
| new-object system.string | Marco Shaw | PowerShell | 2 | 08-02-2007 02:11 AM |
| Using group-object with a variable string | Marco Shaw | PowerShell | 4 | 12-13-2006 10:47 AM |
| Any way(s) to pass an IComparer object instance to ArrayList.sort? | Sung M Kim | PowerShell | 4 | 11-27-2006 09:23 PM |
| How TO: Reference an Object Property in a String | Brandon Shell | PowerShell | 2 | 08-17-2006 03:38 PM |