Powershell parse

Hello, I am trying to parse out the MoneyLines and Spread values for all the bookies from opening to the last one in this case Wynn Las Vegas. Since the Wynn is an image provide the link instead.

The current code is in the right place and gets me odds. I just dont know how to extract I just need to add the link to each line. I got "opening" but cant seem to get link value

$url = "http://www.oddsshark.com/nfl/new-york-miami-odds-october-4-2015"
$result = Invoke-WebRequest $url
$elements = $result.AllElements | Where Class -eq "books" | Select-Object -Property innerhtml -ExpandProperty innerText
 
#[string[]]$resultArray
$resultArray = $null
$resultArray = @()

foreach ($element in $elements.Split("`n"))
{
	if ($element.Length -gt "2")
	{ $resultArray += $element }
}

$resultArray

Open in new window


Here is what the items look like:
innerHTML                  : <DIV class=book_name><A href="http://www.wynnlasvegas.com/" target=_blank><IMG src="http://cdn3.oddsshark.com/cdn/farfuture/JRfG6lB0qVjsfUat_2 
                             Ws4ZAR108CSOwxklCrx3WZBB0/mtime:1439901983/sites/all/themes/skeletontheme/images/sportsbooks/sblogo_wynn2x.png"> </A></DIV>                    
                             <DIV class=total><SPAN>42</SPAN> </DIV>                                                                                                        
                             <DIV class=over_under><SPAN class=over>o -110 </SPAN><SPAN class=under>u -110 </SPAN></DIV>                                                    
innerText                  :  42 o -110 u -110                                                                                                                              

Open in new window


I need to extract
http://www.wynnlasvegas.com/

Open in new window


for every line
LVL 8
Leo TorresSQL DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
If you need to parse HTML from PowerShell, I would use the HTML Agility Pack, as shown here:

HTML Agility Pack Rocks Your Screen Scraping World
http://www.leeholmes.com/blog/2010/03/05/html-agility-pack-rocks-your-screen-scraping-world/
0
Leo TorresSQL DeveloperAuthor Commented:
I tried that one but i was more complicated for me. The code above has 95% done. Is there any way I could just add one more column with that source link? Else I would have to go back to previous version that was not as far along.
0
Bob LearnedCommented:
Would you want to use a regular expression to get the anchor?

<a[^>]*>([^<]+)</a>

<a[\s]+([^>]+)>((?:.(?!\<\/a\>))*.)</a>
0
What were the top attacks of Q1 2018?

The Threat Lab team analyzes data from WatchGuard’s Firebox Feed, internal and partner threat intelligence, and a research honeynet, to provide insightful analysis about the top threats on the Internet. Check out our Q1 2018 report for smart, practical security advice today!

Leo TorresSQL DeveloperAuthor Commented:
Ok where do I get and set the anchor.

I thought this line is what gave me my anchor
Where Class -eq "books" 

Open in new window

0
Leo TorresSQL DeveloperAuthor Commented:
I guess if I am bot being clear is that I need the href for each line of innertext not sure how to get them together.  I can get then separately but not together.

above gets me innertext correct but I need the link soource provided by this line
$result.links | Where {$_.target -like "_blank" } | Select href 

Open in new window


$result defined in main code
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The issue is that
| Select-Object -Property innerhtml -ExpandProperty innerText

Open in new window

doesn't work. You are only getting the expanded strings from innerText. This is how it works - you can only use a single property when using -ExpandProperty.
$url = "http://www.oddsshark.com/nfl/new-york-miami-odds-october-4-2015"
Invoke-WebRequest $url |
  Select -Expand AllElements |
  Where Class -eq "books" |
  ? { $_.InnerText.Length -gt 10 } |
  Where InnerHTML -match '.*A href="([^"]*)"' |
  % { $_.InnerText + "`t" + $matches[1] }

Open in new window

0
Leo TorresSQL DeveloperAuthor Commented:
Sorry for delay but yeah that pretty much covers it. I am just missing 1 line. The opening Line

-130 +110 Even   Even  Opening 

Open in new window

0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The "opening" lines do not have a HREF. If you need them:
$url = "http://www.oddsshark.com/nfl/new-york-miami-odds-october-4-2015"
Invoke-WebRequest $url |
  Select -Expand AllElements |
  Where Class -eq "books" |
  ? { $_.InnerText.Length -gt 10 } |
  % {
    $_.InnerText + $(if ($_.InnerHTML -match '.*A href="([^"]*)"') { "`t" + $matches[1] } )
  }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Leo TorresSQL DeveloperAuthor Commented:
WOW!. that's impressive  Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.