Skip to content

Instantly share code, notes, and snippets.

@Lukasa Lukasa/LICENSE
Last active Feb 24, 2017

Embed
What would you like to do?
AirPods via Twilio
#!/usr/bin/env python
"""
A small Python script that checks whether I can buy AirPods.
Yes, really. DON'T JUDGE ME!
"""
import time
import requests
from twilio.rest import TwilioRestClient
# INSERT TWILIO CREDENTIALS HERE
TWILIO_ACCOUNT_SID = ""
TWILIO_AUTH_TOKEN = ""
TARGET_URL = 'http://www.istocknow.com/live/alert.php'
twilio_client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
s = requests.Session()
# INSERT COOKIE HERE
s.cookies['iStockNow'] = ''
twilio_client.messages.create(
to="+447549929821",
from_="+441173253963",
body="Starting scanning."
)
while True:
time.sleep(30)
r = s.get(TARGET_URL, params={'mode': 'livecheck'}, timeout=30)
if r.status_code != 200:
print("Received non-200 code")
twilio_client.messages.create(
to="+447549929821",
from_="+441173253963",
body="Received non-200 status code"
)
time.sleep(600)
continue
data = r.json()
if data['result'] == 0:
# Nothing is happening
print("Nothing of note")
continue
print("Got something!")
body_data = r.content.decode('utf-8')
twilio_client.messages.create(
to="+447549929821",
from_="+441173253963",
body="Update: {}".format(body_data)
)
break
Copyright (c) 2017 Cory Benfield
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.