Skip to content

Instantly share code, notes, and snippets.

@terremoth
Created December 24, 2024 14:02
Show Gist options
  • Save terremoth/a2b81fbaf5bb390a4a274bd8fbbe5016 to your computer and use it in GitHub Desktop.
Save terremoth/a2b81fbaf5bb390a4a274bd8fbbe5016 to your computer and use it in GitHub Desktop.
get page id from URL
$url = $args[0]
try {
$response = Invoke-WebRequest -Uri $url
} catch {
Write-Output $_.Exception
if ($_.Exception.Response.StatusCode -eq "404") {
Write-Host "Error: Page does not exist"
} else {
Write-Host "Error: Page could not be processed" -ForegroundColor red -BackgroundColor black
}
Exit
}
$content = $response.Content | select-string -Pattern "<!-- POST ID: (\d+) -->"
if ($content) {
# Write-Host $content.Matches.Value
$postId = $content.Matches.Groups[1].Value
Write-Host $postId
} else {
Write-Host "POST ID not found."
}
@terremoth
Copy link
Author

$pageIdPath = ".\pageid.ps1"

$result = & $pageIdPath $args[0].trim()

$origemPath = ".\origem.bat"

$result = & $origemPath $result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment