Reverse Engineering Dynamic Pricing Using Python

Imagine buying a share of stock without having the price history.

That’s exactly what purchasing retail items online is like.

You don’t have enough historical information to understand if a current price (whether its a listed sale or not) is truly a good deal.

We’ve built Waldo to help with this: rather than track prices every day waiting for the lowest price, we let you shop now and get you your money back when prices drop.

Enough talk.

Go buy yourself a Minion keychain.

Just get it at the lowest price.

Or just signup for Waldo.

Appendix:How we built the test:To grab the data for each price change, we used the script below.

It ran every 15min during the experiment.

const puppeteer = require('puppeteer');(async () => { // Open brower and go to the minion page const browser = await puppeteer.

launch(); const page = await browser.

newPage(); await page.



com/p/minion-movie-short-standard-minion-2-eyes-clip-on-5-plush/-/A-75480917'); const text = await page.

evaluate(() => { // Grab the price using an XPATH const price = document.

evaluate( 'string(//div/div/span[@data-test="product-price"][1]/text())', document ).

stringValue; return price; }); // Save the time, screenshot, and minion price to a file let time = Math.

round(+new Date() / 1000); await page.

screenshot({ path: '.

/pics/' + time + '_' + text + '_minion.

png' }); await browser.

close();Combining the screenshots and charts:from PIL import Image# grab the screenshot and chart and combine:def merge_img(img1_path, img2_path, name): files = [img1_path, img2_path] result = Image.

new("RGB", (1600, 600)) size = 800 for index, file in enumerate(files): path = os.


expanduser(file) img = Image.

open(path) img.

thumbnail((size, size), Image.

ANTIALIAS) x = index % 2 * size y = index // 2 * size w, h = img.

size result.

paste(img, (x, y, x + w, y + h)) save_path = '.

/combined_img/' + name.


png')[0] + '_combined.

png' result.



expanduser(save_path))Creating the video using ffmpeg:ffmpeg -f image2 -pattern_type glob -framerate 45 -i '*.

png' -c:v libx264 -r 30 -pix_fmt yuv420p out.


. More details

Leave a Reply