Home > Mobile >  Trying to grab text from Generator in Powershell
Trying to grab text from Generator in Powershell

Time:01-21

I'm trying to use a

Invoke-WebRequest -Uri https://www.lingerandlook.com/Names/StreetNameGenerator.htm |Select-Object yadda yadda

to get a 3 word "sweet street name" from this site but I am unable to get it to get the right content or find the text when parsing the site. Can someone help me?

Tried to find content on page in powershell but am unable to see the text generated only that it's spanid is $name. I'm generally new to powershell so unsure of how to move forward

CodePudding user response:

In this particular case, you can get the list of generated street names from that site like this:

$request = Invoke-WebRequest -Uri 'https://www.lingerandlook.com/Names/StreetNameGenerator.htm'
$table   = @($request.ParsedHtml.getElementsByClassName('tlist'))[0]

$table.deleteRow(0) # remove the top table row 'If you want to invent your own name...'

# next move through all the data rows and join the content of its cells to form a street name
$streetList = foreach ($row in $table.Rows) {
    ($row.Cells | ForEach-Object { $_.innerText }) -join ' '
}

# output the resulting array to console
$streetList

# or save it to some file
$streetList | Set-Content -Path 'X:\Somewhere\StreetList.txt'

Result

Amber Acorn Acres
Auburn Anchor Alcove
Bent Apple Arbor
Big Autumn Avenue
Birch Axe Bank
Blue Barn Bayou
Bright Beacon Bend
Broad Bear Bluff
Burning Beaver Byway
Calm Berry Canyon
Cinder Bird Chase
Clear Blossom Circle
Cold Bluff Corner
Colonial Branch Court
Cool Bridge Cove
Cotton Brook Crest
Cozy Butterfly Cut
Crimson Butternut Dale
Crystal Castle Dell
Dewy Chestnut Drive
Dusty Cider Edge
Easy Cloud Estates
Emerald Cottage Falls
Fallen Creek Farms
Foggy Crow Field
Gentle Dale Flats
Golden Deer Gardens
Grand Diamond Gate
Green Dove Glade
Happy Elk Glen
Harvest Elm Grove
Hazy Embers Haven
Heather Fawn Heights
Hidden Feather Highlands
High Flower Hollow
Honey Forest Isle
Hush Fox Jetty
Indian Gate Journey
Iron Goat Knoll
Ivory Goose Lace
Jagged Grove Lagoon
Lazy Harbor Landing
Little Hickory Lane
Lone Hills Ledge
Lonely Holly Manor
Long Horse Meadow
Lost Island Mews
Merry Lake Niche
Middle Lamb Nook
Misty Leaf Orchard
Noble Log Pace
Old Maple Park
Orange Mill Pass
Pearl Mountain Path
Pied Nectar Pike
Pleasant Nest Place
Pretty Nut Point
Quaint Oak Promenade
Quaking Panda Quay
Quiet Peach Race
Red Pebble Ramble
Rocky Pine Ridge
Rose Pioneer Road
Rough Pond Round
Round Pony Rove
Rustic Prairie Run
Sandy Pumpkin Saunter
Shady Quail Shoal
Silent Rabbit Stead
Silver Rise Street
Sleepy River Stroll
Small Robin Summit
Square Rock Swale
Still Shadow Terrace
Stony Sky Trace
Strong Snake Trail
Sunny Spring Trek
Sweet Squirrel Turn
Tawny Stone Twist
Tender Swan Vale
Thunder Timber Valley
Turning Treasure View
Twin Turtle Villa
Umber View Vista
Velvet Wagon Wander
White Willow Way
Windy Zephyr Woods
  • Related