Easily scrape the stock level's of your favourite IKEA Products, all from the comfort of your python shell
-
Go to the website of the IKEA Region of your choice. In this case, IKEA UK
-
Find a random item. In this case, BLÅHAJ Soft toy, shark, 100 cm
-
Find the Stock Checker, this should be a Drop Down box, enter Inspect Element on this Element.
-
Copy the inner data from that Element. It should look something like:
<select class="range-dropdown range-dropdown--with-label" id="new-stockcheck-dropdown"> <option class="range-dropdown__option--disabled" value="" disabled="">Select a store</option> <option value="113">Belfast</option> <option value="142">Birmingham</option> ... </select>
-
Remove the
<select class="range-dropdown range-dropdown--with-label" id="new-stockcheck-dropdown"> <option class="range-dropdown__option--disabled">...</option>
and the remaining</select>
from your copied HTML -
From here you can manually convert the HTML in to a JSON array by using a tool like Find and Replace in your editor of choice.
-
Substitute
</option>
for","
-
Substitute
">
for": "IKEA
-
Substitute
<option value="
for nothing. -
Make sure to remove the trailing comma from the last entry in your newly converted JSON.
-
Create a new entry in the
stores.json
file with the country code of the stores country you have just converted. -
Paste your converted code in to the new entry. It should look something like this:
{ "gb": { "113": "IKEA Belfast", "142": "IKEA Birmingham", ... }, ... }
-
-
Create a new pull request with your updated
stores.json
file.