<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashwini Kalantri on Medium]]></title>
        <description><![CDATA[Stories by Ashwini Kalantri on Medium]]></description>
        <link>https://medium.com/@ashwinikalantri?source=rss-73161903a226------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VHDRk4-EPQqlkB1CJWQPIA.jpeg</url>
            <title>Stories by Ashwini Kalantri on Medium</title>
            <link>https://medium.com/@ashwinikalantri?source=rss-73161903a226------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 05:36:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashwinikalantri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Amazon and I]]></title>
            <link>https://medium.com/@ashwinikalantri/amazon-and-i-54d51e93b9be?source=rss-73161903a226------2</link>
            <guid isPermaLink="false">https://medium.com/p/54d51e93b9be</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[ipad]]></category>
            <category><![CDATA[amazon]]></category>
            <dc:creator><![CDATA[Ashwini Kalantri]]></dc:creator>
            <pubDate>Tue, 21 Jul 2020 09:03:32 GMT</pubDate>
            <atom:updated>2020-07-22T06:54:06.939Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pRSHk6sGItGW-hu1" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I always thought that the iPad was a gimmick. The now ancient iPad 2 that I used many years ago did not help change my mind. The iOS 13 last year was a pleasant change in the way the iPad worked and got me interested again. The iPad seemed usable again. The 2020 iPad Pro was launched and my heart was set on one.</p><p>I did the obvious thing. Went on Amazon to snag one up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/0*5SfbRhGmqMhTJQ_m" /><figcaption>The iPad was unavailable on Amazon</figcaption></figure><p>Flipkart, chroma, reliance digital, paytm were all stocked out. I contacted the nearest Apple store. All I got was a rant about how the pandemic was hampering the supply chains. They did not have stock and had no timeline.</p><p>Disheartened, I thought I should wait. That’s the only thing I could do. I would frequently visit Amazon’s iPad product page to check its availability. I saw other models come and go out of stock, but not the one I had my eye on. Also, these other models would only remain in stock for a few minutes and then disappear.</p><p>There was a non-negative chance that my model also would have its 5 minutes of fame and disappear. But there was no way for me to know this. Amazon doesn’t notify you when a product becomes available to buy. You have to be at the right place at the right time.</p><p>I decided to take the matter on my own hands. I wasn’t going to rely on pure luck to get me that iPad. I decided to code my way to get that iPad.</p><p>I am a novice coder and have only recently started learning R. I wrote a small script that would check the iPad’s link on Amazon’s website, look for its availability and email me back if it is available. Seemed straightforward. Reading Amazon’s web page and locating the section with availability wasn’t hard. The script was able to read the text that said if the item was availabe or not. Every time this text would say <em>“Currently unavailable.”</em> , the script would do nothing. Wait for a minute and check again. But if the text said anything other than <em>“Currently unavailable”</em>, the script would send me an email along with the link to buy the iPad. And then stop.</p><p>There was a problem with this method. Every time the email got triggered, the script would stop and I had to manually re-run it. Also, the script was potentially an infinite loop as long as the availability didn’t change. If there was any error, the script would stop, requiring manual intervention. Not the most elegant solution.</p><p><strong>Version 2.0</strong></p><p>I simplified the script to only check for availability and report if available. No loops. Instead I set up a cron job on my R Server to trigger the script every minute. This did the trick. I was able to loop the script for as long as the job was in place and the loop didn’t get disrupted even if there was an one of error running it. This also allowed me to log the output in a log file. Now every time the script ran, the log file got updated with either iPad unavailable or email sent. If there was an error running the script, that would also get logged and I could have a look. Elegant enough?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uXjoOIpXGFoDC3io" /><figcaption>My script was checking the availability every minute</figcaption></figure><p>This went on for a day. And…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEgbw9QwDLmIqGnrd9PhMg.png" /><figcaption>Amazon stops sending me the HTML code</figcaption></figure><p>My log was full of this error. And I couldn’t imagine why? What happened that led my script, that was running flawlessly a day before, to start crashing? I did a bit of digging and instead of the HTML code of the Amazon’s iPad webpage, Amazon started to send me this:</p><blockquote>To discuss automated access to Amazon data please contact api-services-support@amazon.com</blockquote><p>A company built around making your shopping experience better and easier, wasn’t having any of it. They were not going to allow a rookie coder use their system the way he wanted.</p><p>My investigations show that Amazon doesn’t like web scraping. And this was one of the many methods that they employ to deter potential ‘<em>bots</em>’ from looking at their pages and mining data. Amazon was able to figure out that the same computer was checking the same page every minute. And it put an end to it. I could sense my defeat. How could I compete with the behemoth that Amazon is.</p><p><strong>Version 3.0</strong></p><p>But then I figured that Amazon was tracking my IP address. I tried to run the script less frequently. That didn’t help. I stopped running it for a few hours, hoping Amazon would forget. They didn’t forget.</p><p>What if I could change my IP address every time I ran the script? And I was able to find a way to just do that. I found a bunch of free proxy server IP addresses online and now every time my script ran, Amazon would think my request was from a different part of the globe.</p><p>Lo and behold, the script started running again! Although I would still get an error here and there. But for all practical purposes, it worked.</p><p><strong>Now we wait…</strong></p><p>The script was buzzing away, checking amazon’s website every minute.</p><p>I got an email from myself saying that the iPad I wanted was available at 2 in the morning one day. By the time I read it next morning, it was out of stock again. Once again, while I was driving. I parked and tried buying it a couple of times. I couldn’t add it to my cart. And it ran out again.</p><p>Saturdays nights are movie nights. Me and my wife caffeinate ourselves and enjoy a movie or two till early hours of the morning. At around midnight, I got another email notifying the availability of the iPad. I again failed to buy it.</p><p><strong>The final battle</strong></p><p>Our movie had ended and the wife was asleep. The coffee kept me from joining her. I was mindlessly scrolling through my reddit feed when I got notified of a new email, from myself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Dw5MZLkaSDSUldaHElCeQ.png" /><figcaption>The email from myself</figcaption></figure><p>It was 4:27 early Sunday morning. I clicked on the link in the mail, and rightly so, the iPad was available. Add to cart, check. Select address, pick payment method, CVV, OTP. Check, check, check and check.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*A0_AGlffT6es6g9uy-h3xg.png" /></figure><p>The adrenaline rush from this<strong> </strong>process<strong> </strong>gave me a bigger kick than the excitement of actually getting the iPad. I wanted to tell someone. But I would rather not wake the wife. So with this sense of achievement and the knowledge that I would get the iPad before Friday, I too dozed off!</p><p><strong>3 days later</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKEuFCvYTS2mlasji-VOQw.jpeg" /><figcaption>The iPad, finally!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54d51e93b9be" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>