r/PowerShell • u/dud380 • Feb 10 '26
I wanted a PowerShell module for browser automation using only PowerShell & .NET
So I built Pup, a wrapper around PuppeteerSharp that talks directly to Chrome via the DevTools Protocol. Works on Windows, Linux, and macOS with PowerShell 5.1+.
Write-Host "This one just scrapes the first page of Ubuntu Notices"
Install-Module -Name Pup
Import-Module Pup
$browser = Start-PupBrowser -Headless
$page = New-PupPage -Browser $browser -Url "https://ubuntu.com/security/notices"
$page | Find-PupElements -Selector "#notices-list section" | ForEach-Object {
[PSCustomObject]@{
Date = ($_ | Find-PupElements -Selector "p.u-text--muted" -First).InnerText
Link = ($_ | Find-PupElements -Selector "h3 a" -First | Get-PupElementAttribute -Name href)
}
}
$browser | Stop-PupBrowserGitHub: https://github.com/n7on/Pup
Happy to hear feedback or answer questions.
34
Upvotes
10
u/BetrayedMilk Feb 10 '26
Is there a reason you went with Puppeteer vs Playwright?
5
u/PutridLadder9192 Feb 11 '26
Very useful I need to webscrape for those hundreds of things winget doesn't do or doesn't keep updated
3
u/skilife1 Feb 10 '26
Looks quite nice! I'll test it out tomorrow.
2
u/Bad_Times_Man Mar 13 '26
This is really cool. Is there any way to open a 2nd, a 3rd, or more windows and manipulate each based off their title or some other identifying detail such as sequential start time?
I'd love to use this to replace the bulk of sleep timers and sendkeys scripting I do now but I can't if it's hard limited to a single window.
1
u/RidiculousAnonymer Feb 11 '26
Starred, will give it a try during weekend.
1
u/MadBoyEvo Feb 12 '26
This is what I created a while back PSParseHTML
I renamed it from old PSParseHTML on github but it's pretty much PSParseHTML in PowerShell still.
This is what it supports:
🔍 HTML Parsing - Multiple parsing engines (AngleSharp, HtmlAgilityPack)
🎨 Resource Optimization - Minify and format HTML, CSS, JavaScript
🌐 Browser Automation - Full Playwright integration for screenshots, PDFs, interaction
📊 Data Extraction - Tables, forms, metadata, microdata, Open Graph
📧 Email Processing - CSS inlining for email compatibility
🔧 Network Tools - HAR export, request interception, console logging
🍪 State Management - Cookie handling, session persistence
📱 Multi-Platform - .NET Framework 4.7.2, .NET Standard 2.0, .NET 8.0
It used to be only AngleSharp and HAP, but had more needs so version 2.0+ has a lot of functionality.
1
u/skilife1 Feb 13 '26
Just 24 hours into my Pup trial, and I can honestly say I'm hooked. Goodbye Selenium. I really appreciate the great work in developing this module.
1
u/Stock-Hamster-117 Feb 19 '26
Nice solution, is their any way to ignore certificates errors?
1
u/nkasco Feb 11 '26
This is probably not as worthwhile with WebMCP emerging tbh