Skip to content

Instantly share code, notes, and snippets.

@seymores
Created April 27, 2017 07:57
Show Gist options
  • Save seymores/1dc586c3bd884186202c5f3f43e09865 to your computer and use it in GitHub Desktop.
Save seymores/1dc586c3bd884186202c5f3f43e09865 to your computer and use it in GitHub Desktop.
Crawling Carousell Part 2
iex(8)> c1 = "https://carousell.com/ui/iso/api-main;localeCookies=true;path=%2F2.1%2Fproducts%2F;query=%7B%22count%22%3A31%2C%22start%22%3A0%2C%22sort%22%3A%22lowest_price%22%2C%22price_start%22%3A2000%2C%22query%22%3A%22rolex%20explorer%2039mm%202016%22%2C%22toggle_shippable%22%3A1%2C%22latitude%22%3A%22%22%2C%22longitude%22%3A%22%22%2C%22lte%22%3A%22%22%2C%22unit%22%3A%22%22%2C%22country_id%22%3A%221880251%22%2C%22country_code%22%3A%22SG%22%7D?_csrf=lY4VP8gA-VL4l1oTBrjxzVwVWronwIMzSPFQ&returnMeta=true"
"https://carousell.com/ui/iso/api-main;localeCookies=true;path=%2F2.1%2Fproducts%2F;query=%7B%22count%22%3A31%2C%22start%22%3A0%2C%22sort%22%3A%22lowest_price%22%2C%22price_start%22%3A2000%2C%22query%22%3A%22rolex%20explorer%2039mm%202016%22%2C%22toggle_shippable%22%3A1%2C%22latitude%22%3A%22%22%2C%22longitude%22%3A%22%22%2C%22lte%22%3A%22%22%2C%22unit%22%3A%22%22%2C%22country_id%22%3A%221880251%22%2C%22country_code%22%3A%22SG%22%7D?_csrf=lY4VP8gA-VL4l1oTBrjxzVwVWronwIMzSPFQ&returnMeta=true"
iex(9)> URI.decode_www_form c1 "https://carousell.com/ui/iso/api-main;localeCookies=true;path=/2.1/products/;query={\"count\":31,\"start\":0,\"sort\":\"lowest_price\",\"price_start\":2000,\"query\":\"rolex explorer 39mm 2016\",\"toggle_shippable\":1,\"latitude\":\"\",\"longitude\":\"\",\"lte\":\"\",\"unit\":\"\",\"country_id\":\"1880251\",\"country_code\":\"SG\"}?_csrf=lY4VP8gA-VL4l1oTBrjxzVwVWronwIMzSPFQ&returnMeta=true"
iex(10)>
nil
iex(11)> c2 = "https://carousell.com/ui/iso/api-main;path=/2.1/products/;query={\"count\":31,\"start\":0,\"sort\":\"recent\",\"price_start\":2000,\"query\":\"rolex explorer 39mm 2016\",\"toggle_shippable\":1,\"latitude\":\"\",\"longitude\":\"\",\"lte\":\"\",\"unit\":\"\",\"country_id\":\"1880251\",\"country_code\":\"SG\"}"
"https://carousell.com/ui/iso/api-main;path=/2.1/products/;query={\"count\":31,\"start\":0,\"sort\":\"recent\",\"price_start\":2000,\"query\":\"rolex explorer 39mm 2016\",\"toggle_shippable\":1,\"latitude\":\"\",\"longitude\":\"\",\"lte\":\"\",\"unit\":\"\",\"country_id\":\"1880251\",\"country_code\":\"SG\"}"
iex(12)> URI.decode_www_form c2 "https://carousell.com/ui/iso/api-main;path=/2.1/products/;query={\"count\":31,\"start\":0,\"sort\":\"recent\",\"price_start\":2000,\"query\":\"rolex explorer 39mm 2016\",\"toggle_shippable\":1,\"latitude\":\"\",\"longitude\":\"\",\"lte\":\"\",\"unit\":\"\",\"country_id\":\"1880251\",\"country_code\":\"SG\"}"
iex(13)> URI.encode_www_form c2
"https%3A%2F%2Fcarousell.com%2Fui%2Fiso%2Fapi-main%3Bpath%3D%2F2.1%2Fproducts%2F%3Bquery%3D%7B%22count%22%3A31%2C%22start%22%3A0%2C%22sort%22%3A%22recent%22%2C%22price_start%22%3A2000%2C%22query%22%3A%22rolex+explorer+39mm+2016%22%2C%22toggle_shippable%22%3A1%2C%22latitude%22%3A%22%22%2C%22longitude%22%3A%22%22%2C%22lte%22%3A%22%22%2C%22unit%22%3A%22%22%2C%22country_id%22%3A%221880251%22%2C%22country_code%22%3A%22SG%22%7D"
iex(14)> c2
"https://carousell.com/ui/iso/api-main;path=/2.1/products/;query={\"count\":31,\"start\":0,\"sort\":\"recent\",\"price_start\":2000,\"query\":\"rolex explorer 39mm 2016\",\"toggle_shippable\":1,\"latitude\":\"\",\"longitude\":\"\",\"lte\":\"\",\"unit\":\"\",\"country_id\":\"1880251\",\"country_code\":\"SG\"}"
iex(15)> cx = "{\"count\":31,\"start\":0,\"sort\":\"recent\",\"price_start\":2000,\"query\":\"rolex explorer 39mm 2016\",\"toggle_shippable\":1,\"latitude\":\"\",\"longitude\":\"\",\"lte\":\"\",\"unit\":\"\",\"country_id\":\"1880251\",\"country_code\":\"SG\"}"
"{\"count\":31,\"start\":0,\"sort\":\"recent\",\"price_start\":2000,\"query\":\"rolex explorer 39mm 2016\",\"toggle_shippable\":1,\"latitude\":\"\",\"longitude\":\"\",\"lte\":\"\",\"unit\":\"\",\"country_id\":\"1880251\",\"country_code\":\"SG\"}"
iex(16)> URI.encode_www_form cx "%7B%22count%22%3A31%2C%22start%22%3A0%2C%22sort%22%3A%22recent%22%2C%22price_start%22%3A2000%2C%22query%22%3A%22rolex+explorer+39mm+2016%22%2C%22toggle_shippable%22%3A1%2C%22latitude%22%3A%22%22%2C%22longitude%22%3A%22%22%2C%22lte%22%3A%22%22%2C%22unit%22%3A%22%22%2C%22country_id%22%3A%221880251%22%2C%22country_code%22%3A%22SG%22%7D"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment