giffgaffbot
Last time I wanted to buy new Samsung Galaxy S 5 I liked blue one but there was no preorder option on giffgaff website (it was cheapest there) so to notify me I wrote a bot in pycurl and placed job in cron to send me an email when ot will be in stock.
Cut of sourcefragment from giffgaff webpage:
<form id="frmBuyPhone" action="/samsung/samsung-galaxy-s5/phone-plans" method="post" data-color-memory-mapping=' {"black":{"16":{"price":"517","sku":"GG1SAS5BBN","stock":1,"isLoanAvailable":true,"minMonthlyPayment":2139,"minAPR":970}}, "white":{"16":{"price":"517","sku":"GG1SAS5WWN","stock":1,"isLoanAvailable":true,"minMonthlyPayment":2139,"minAPR":970}}, "blue":{"16":{"price":"517","sku":"GG1SAS5BLN","stock":1,"isLoanAvailable":true,"minMonthlyPayment":2139,"minAPR":970}}, "gold":{"16":{"price":"517","sku":"GG1SAGS5GN","stock":1,"isLoanAvailable":true,"minMonthlyPayment":2139,"minAPR":970}}}' data-loan-mapping='{"GG1SAS5BBN":{"5000":{"24":{"deal_id":"7049","apr":970,"loan_amount":46700,"monthly_payment":2139,"total_payment":56336},"18":{"deal_id":"7053","apr":1140,"loan_amount":46700,"monthly_payment":2821,"total_payment":55778},"12":{"deal_id":"7057","apr":1470,"loan_amount":46700,"monthly_payment":4187,"total_payment":55244},"6":{"deal_id":"7061","apr":2580,"loan_amount":46700,"monthly_payment":8317,"total_payment":54902}}
The bot looks like this :
and added job to crontab to check every 5 minutes
*/5 * * * * /workspace/projects/checkbot/readweb.py
Comments
Comments powered by Disqus