Sat Sep 24 2022
I’ve been exploring ways to make money outside my 9-5 for the past few weeks. One idea that has been bouncing around my head is to build bots that buy exclusive items like concert tickets or Nike sneakers and then reselling them. This idea isn’t new territory by any means (~40% of all transactions on TicketMaster are from bots).
However, there is something that rubs me the wrong way about buying tickets to concerts and then reselling them. I love concerts so it seems slimy to steal tickets from people who have waited years to see their favorite artist. Regardless, TicketMaster is cracking down on security to prevent this from happening; so even if I did spend the 20 hours I estimated it would take to build a bot that could circumnavigate TicketMaster's anti-bot measures, I would still be competing with everyone else’s bots.
But, I still wanted to dip my feet in the world of building bots to buy items. So fast forward to a few days ago and I was at the mall with my girlfriend: she wanted to go into Lululemon to get this trending item called a belt bag. I’ve seen people wearing them before but had no idea they were so trendy. Basically they are sold out everywhere, in all stores and online. A quick search on eBay showed me they had a resale value of $120, pretty good, considering they retail for $38. So I saw an opportunity: build a bot to alert me when they restock and then resell on eBay for a little profit.
The script was pretty quick to build maybe 25 minutes and then deploying to a server and making the cron job was another 20 minutes. The script essentially checks if the HTML of the product page contains "availability":"InStock"' and if so an if statement passes which calls Twilio’s API to call my phone number. I could’ve used Selenium to actually buy the belt bags for me but I decided to keep it simple for the first iteration.
import requests
import bs4
from twilio.rest import Client
headers = {"User-Agent":"Mozilla/5.0"}
url = "https://shop.lululemon.com/p/bags/Everywhere-Belt-Bag/_/prod8900747?sz=ONESIZE"
response = requests.get("https://shop.lululemon.com/p/bags/Everywhere-Belt-Bag/_/prod8900747?sz=ONESIZE", headers=headers)
soup = bs4.BeautifulSoup(response.content, "html.parser")
soupStr = str(soup)
if '"availability":"InStock"' in soupStr:
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)
call = client.calls.create(
twiml='<Response><Say>The Belt Bag is in stock.</Say></Response>',
to='+myPhoneNumber',
from_='+twiliosPhoneNumber'
)
textBeltKey = os.environ['TEXTBELT_API_KEY']
payload = {
'phone': 'myPhoneNumber',
'message': ("Belt Bag is Back in Stock: "+ url),
'key':textBeltKey
}
resp = requests.post('https://textbelt.com/text', payload)
Then a cron job then just runs the script every minute. Simple right?
* * * * * /usr/bin/python3 /home/alex/lulu/lulu.py
So I finished coding and setting up the code on my Digital Ocean server around 11 PM. I went to bed and ironically I got the phone call that same night at 6:12 AM. That was fast, I thought as the sun was rising and I got out of bed.
I opened up my laptop, went to Lululemon’s website, and added 10 of the White Opal Belt Bags to my cart (GF said White Opal was the most popular) … and then my credit card gets declined, “hmm weird” I thought. I enter it again, check everything and it gets declined again. I grab another card to use but the bags were sold out by the time I re-entered everything. They sold out in 18 minutes. Other people must have built bots too, I assumed. So disappointed (and confused why my card got declined) I went back to bed for a few hours.
I then woke up the next morning and I get the below text from my Dad. He (rightfully so) thought my card had fraud and canceled the card. Annoying, but understandable.
Anyway, I reactivated the script when I woke up, and started my day. A few hours later while I’m eating lunch I get another call from Twilio. "Seriously? They are in stock again?" I open my computer for round two, used my debit card this time, and managed to buy them. Nice.
I listed the bags on eBay right after I placed the order. The bags come in today and I’ve already sold all but one. Not bad.
All in all, despite waking up at 6 AM and having my credit card wrongly canceled I was pleased with this experiment. I made a bit of money, learned how Twilio’s API works, and had fun coding the script.
More bots coming soon.
Till next time, Alex.