Created
June 16, 2022 13:09
-
-
Save Ertavf/574c2a088e60da96f581de4acaf1f73b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# "According to company rules, a bus can only have three seats. To replace seat 29, you have to buy seat 19, 25." | |
# As a result of having trouble getting a bus ticket from a company that says the above | |
# I wrote this script to be notified when someone else buys a ticket. | |
# get | |
Function GetResponse() { | |
$session = New-Object Microsoft.PowerShell.Commands.WebRequestSession | |
# removed cookies | |
$response = Invoke-WebRequest -UseBasicParsing -Uri "https://shop.removed.com.tr/ancillaries/premium-seat/by-trip?tripId=156742631%3A47602%3A48831&legId=156742631%3A47602%3A48831&genders_female=0&genders_male=1" ` | |
-WebSession $session ` | |
-Headers @{ | |
"authority"="shop.flixbus.com.tr" | |
"method"="GET" | |
"path"="/ancillaries/premium-seat/by-trip?tripId=156742631%3A47602%3A48831&legId=156742631%3A47602%3A48831&genders_female=0&genders_male=1" | |
"scheme"="https" | |
"accept"="*/*" | |
"accept-encoding"="gzip, deflate, br" | |
"accept-language"="en-US,en;q=0.9,tr;q=0.8,de;q=0.7" | |
"referer"="https://shop.flixbus.com.tr/checkout" | |
"sec-ch-ua"="`" Not A;Brand`";v=`"99`", `"Chromium`";v=`"101`", `"Google Chrome`";v=`"101`"" | |
"sec-ch-ua-mobile"="?0" | |
"sec-ch-ua-platform"="`"Linux`"" | |
"sec-fetch-dest"="empty" | |
"sec-fetch-mode"="cors" | |
"sec-fetch-site"="same-origin" | |
} | |
return $response | |
} | |
$r = GetResponse | |
#############################################################3\ | |
# DANGER ZONE | |
# manually run the lines below to set the old content | |
# $r.Content > ./kamil.json | |
# more ./kamil.json | |
#############################################################3\ | |
# read the oldContent.json file | |
$oldContent = Get-Content kamil.json | |
# compare the Content with the oldContent.json file | |
$isContentSame = $r.Content.Equals($oldContent) | |
Write-Debug "Content is same: $isContentSame" | |
# if the content is not the same, send a notification by ifttt | |
if ($isContentSame -eq $false) | |
{ | |
$body = {Mesaj = "oto mesaj: Otobüs koltuklarında değişiklik var"} | |
$EventName = "Kamil" | |
# DANGER ZONE | |
# make sure the ifttt webhook is set up | |
$EventKey = "removed the key" | |
$webhookUrl = "https://maker.ifttt.com/trigger/{0}/json/with/key/{1}" -f $EventName, $EventKey | |
# send the notification | |
Invoke-RestMethod -Method Post -Uri $webhookUrl -Body $body | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment