-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathExample5.ps1
More file actions
76 lines (58 loc) · 2.88 KB
/
Copy pathExample5.ps1
File metadata and controls
76 lines (58 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<#
The following example called 'tribute to Snover' grasps information for the 'shellfather' from around the internet, adn generates a html page with the information.
# This example ilustrates how we can leverage the power of powershell, to fetch and filter information on various websites (using invoke-webrequest)
We use foreach to create multiple <p> or <li> elements.
#>
import-module pshtml
$Snover = Html {
header -content {
Title "Tribute to snover"
Write-PSHTMLAsset
link -rel stylesheet -href "MyStyles.css"
}
Body{
h1 "Tribute to Jeffrey Snover" -Class "Title"
div -Class "Photo" {
img -src "https://pbs.twimg.com/profile_images/1039650689620688896/ZZgN5c9Y_400x400.jpg" -alt "Jeffrey Snover photo" -height "400" -width "400" -Class "Photo"
}
div -id "Bio" {
$WikiRootSite = "https://en.wikipedia.org"
$Source = a {"Wikipedia"} -href $WikiRootSite
h2 "Biography"
h4 "Source --> $Source"
#Gathering the biography information from Wikipedia
$wiki = Invoke-WebRequest -Uri ($WikiRootSite + "/wiki/Jeffrey_Snover")
$Output = $Wiki.ParsedHtml.getElementById("mw-content-text").children | Where-Object -FilterScript {$_.ClassName -eq 'mw-parser-output'}
$Bio = $Output.Children | Where-Object -FilterScript {$_.TagName -eq 'p'} | Select-Object -Property Tagname,InnerHtml
foreach ($p in $bio){
if($p.InnerHtml -ne $null){
#The url are relative on Wiki website. Correcting it here so that the Links are still working
$Corrected = $p.innerHTML.Replace("/wiki/","$WikiRootSite/wiki/")
p{
$Corrected
}
}
}
}#End Accomplishements
Div -id "Snoverisms" {
$SnoverismsSite = "http://snoverisms.com/"
h2 "Snoverisms"
h4 "Source --> $SnoverismsSite"
$Page = Invoke-WebRequest -Uri $SnoverismsSite
$Snoverisms = $Page.ParsedHtml.getElementsByTagName("p") | Where-Object -FilterScript {$_.ClassName -ne "site-description"} | Select-Object -Property innerhtml
$Snoverisms += (Invoke-WebRequest -uri "http://snoverisms.com/page/2/").ParsedHtml.getElementsByTagName("p") | Where-Object -FilterScript {$_.ClassName -ne "site-description"} | Select-Object -Property innerhtml
ul -id "snoverism-list" -Content {
Foreach ($snov in $Snoverisms){
li -Class "snoverism" -content {
$snov.innerHTML
}
}
}#end of ul
}
}
Footer{
$PSHTMLlink = a {"PSHTML"} -href "https://github.com/Stephanevg/PSHTML"
h6 "Generated with $($PSHTMLlink)"
}
}
$Snover > "Example5.html"