Skip to content

Instantly share code, notes, and snippets.

@jwmoss
Last active July 31, 2020 04:08
Show Gist options
  • Save jwmoss/0d8f12399c553dfc38ef9fab852bf4b5 to your computer and use it in GitHub Desktop.
Save jwmoss/0d8f12399c553dfc38ef9fab852bf4b5 to your computer and use it in GitHub Desktop.
#requires -Module PowerHTML
Function Get-PennyStockPumpDump {
[CmdletBinding()]
param (
[switch]
$All
)
$url = "https://pumpadump.com/"
$page = Invoke-WebRequest $url
$rawhtml = ConvertFrom-Html $page.RawContent
$json = (($rawhtml.SelectNodes("/html/body/script[5]/text()").Innertext -split "`n") -split "//")
$jsonfinal = ("[" + $json[4] -replace ",") + "]"
$lookupTable = @{
"stock" = '"stock"'
"mentions" = ', "mentions"'
"sentiment" = ', "sentiment"'
"score" = ', "score"'
"price" = ', "price"'
"}{" = '},{'
}
$jsonfinal | ForEach-Object {
$line = $_
$lookupTable.GetEnumerator() | ForEach-Object {
if ($line -match $_.Key) {
$line = $line -replace $_.Key, $_.Value
}
}
$line
} | ConvertFrom-Json -Depth 99 | ForEach-Object {
$stock = $_.stock
[int]$mentions = $_.mentions
$sentiment = $_.sentiment
[float]$score = $_.score
[float]$price = $_.price -replace '[^0-9.]'
if ($All) {
[PSCustomObject]@{
stock = $stock
mentions = $mentions
sentiment = $sentiment
score = $score
price = $price
}
}
else {
if ($price -lt 5) {
[PSCustomObject]@{
stock = $stock
mentions = $mentions
sentiment = $sentiment
score = $score
price = $price
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment