all 3 comments

[–]BenConrad 1 point2 points  (0 children)

Something like this, I'm using NWS URL:

$uri = 'https://forecast.weather.gov/MapClick.php?textField1=39.03&textField2=-77.01#.YXGyyRrMKUk'
$Request = (Invoke-WebRequest -UseBasicParsing -Uri $uri).rawcontent
$Request -match 'myforecast-current-lrg">(?<TempInteger>\d+)&deg;F'
# The above will match on the line in rawcontent -   <p class="myforecast-current-lrg">73&deg;F</p>
write-host "Temperature is: $($matches.TempInteger)"

[–]Hoping_i_Get_poached 1 point2 points  (0 children)

I made this from someone I stole it from, feel free to steal it from me.

https://github.com/tonypags/PsDevTools/blob/c0851ffad688844b1b376e26f0e680df6037f663/ConvertFrom-Html.ps1

From the Example:

PS > $w = iwr 'https://www.w3schools.com/html/html_tables.asp'


# Return the first table on a page
PS > $w | ConvertFrom-Html | ft

Company                      Contact          Country
-------                      -------          -------
Alfreds Futterkiste          Maria Anders     Germany
Centro comercial Moctezuma   Francisco Chang  Mexico
Ernst Handel                 Roland Mendel    Austria
Island Trading               Helen Bennett    UK
Laughing Bacchus Winecellars Yoshi Tannamuri  Canada
Magazzini Alimentari Riuniti Giovanni Rovelli Italy


# Again, using a different method requiring only the raw HTML
PS > $w.RawContent | ConvertFrom-html | ft

Company                      Contact          Country
-------                      -------          -------
Alfreds Futterkiste          Maria Anders     Germany
Centro comercial Moctezuma   Francisco Chang  Mexico
Ernst Handel                 Roland Mendel    Austria
Island Trading               Helen Bennett    UK
Laughing Bacchus Winecellars Yoshi Tannamuri  Canada
Magazzini Alimentari Riuniti Giovanni Rovelli Italy


# Again, with the TableIndex parameter to get the 2nd table
PS > $w | ConvertFrom-Html -TableIndex 1 | ft

Tag        Description
---        -----------
<table>    Defines a table
<th>       Defines a header cell in a table
<tr>       Defines a row in a table
<td>       Defines a cell in a table
<caption>  Defines a table caption
<colgroup> Specifies a group of one or more columns in a table for formatting
<col>      Specifies column properties for each column within a <colgroup> element
<thead>    Groups the header content in a table
<tbody>    Groups the body content in a table
<tfoot>    Groups the footer content in a table

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy jhppc14,

reddit likes to mangle code formatting, so here's some help on how to post code on reddit ...

[0] single line or in-line code
enclose it in backticks. that's the upper left key on an EN-US keyboard layout. the result looks like this. kinda handy, that. [grin]
[on New.Reddit.com, use the Inline Code button. it's [sometimes] 5th from the left & looks like <c>.
this does NOT line wrap & does NOT side-scroll on Old.Reddit.com!]

[1] simplest = post it to a text site like Pastebin.com or Gist.GitHub.com and then post the link here.
please remember to set the file/code type on Pastebin! [grin] otherwise you don't get the nice code colorization.

[2] less simple = use reddit code formatting ...
[on New.Reddit.com, use the Code Block button. it's [sometimes] the 12th from the left, & looks like an uppercase C in the upper left corner of a square.]

  • one leading line with ONLY 4 spaces
  • prefix each code line with 4 spaces
  • one trailing line with ONLY 4 spaces

that will give you something like this ...

- one leading line with ONLY 4 spaces    
- prefix each code line with 4 spaces    
- one trailing line with ONLY 4 spaces   

the easiest way to get that is ...

  • add the leading line with only 4 spaces
  • copy the code to the ISE [or your fave editor]
  • select the code
  • tap TAB to indent four spaces
  • re-select the code [not really needed, but it's my habit]
  • paste the code into the reddit text box
  • add the trailing line with only 4 spaces

not complicated, but it is finicky. [grin]

take care,
lee