Close

In pursuit of a 1-click BOM

A project log for Kit Space

An site to share buildable kits

kaspar-emanuelKaspar Emanuel 05/25/2016 at 03:132 Comments

This project really started over a year ago, scratching my own itch. I work as an electronic design engineer and purchasing the parts for my designs seemed to be one of the most tedious tasks. I thought to myself: "That should be fairly easy to automate. These are all web-requests after all."

Some retailers do have their quick-paste forms and sharing BOM features but they all use different formats and conventions. Moreover, sometimes you have some parts you can only get from certain places and others only from others, all for the same project.

I wanted to be able to store a single file in my project directory with which I can easily purchase all the necessary parts. A file I could also send my friend or colleague or someone across the world and they could purchase the same parts, no matter what. I wanted a 1-click BOM.

I decided I would make a browser extension to drive the sites, how hard could it be? Well when dealing with ASP retailer sites the question should really be: How ugly can it get?

curl 'http://uk.mouser.com/ProductDetail/Cree-Inc/CGHV96100F2/?Cree-Inc%2fCGHV96100F2%2f&qs=sGAEpiMZZMvplms98TlKY6zbNRoARcUg8gg333Al67kStE%252bN8N0%2fKg%3d%3d'-H 'Cookie: g11n=Up9NRXFGLVs=;ME_Main=&ME_DSN=kJ0slznDUsNJMyNjQRiw8Q==&ME_DSU=YyaQEeoCnLc=;ASP.NET_SessionId=zxtlgy45oobekaaphyv5n0z1;_op_aixPageId=a2_60d31424-8123-4e84-b3f9-a18a6f8bfc3d-3648-87767;CARTCOOKIEUUID=c46df9ef-39bb-4ada-bfcd-2452ed49bc8a; _gat=1;__ar_v4=5UM3NRP3LFFG5JUPQ2VEXA%3A20150203%3A12%7CVPQ73SPSLBEPXM7QJ2MJRL%3A20150203%3A12%7CA463QQQT6VDSDG1=12; SDG2=40; SDG3=0; preferences=ps=gb&pl=en-GB&pc_gb=GBP;_ga=GA1.2.91020740.1409853093;__utma=261309969.91020740.1409853093.1417720020.1422769855.8;__utmb=261309969.15.10.1422769855; __utmc=261309969;__utmz=261309969.1409853093.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);__utmv=261309969.|14=MYM=1638924=1^16=UV=5423887=1^18=Sub=1795089=1^19=PCAT=5367B8=1;__atuvc=1%7C5; __atuvs=54cdc5eabb3480fd000; __utmli=ctl00_ContentMain_btnBuy2'-H 'Origin: http://uk.mouser.com' -H 'Accept-Encoding: gzip, deflate' -H'Accept-Language: en-GB,en-US;q=0.8,en;q=0.6' -H 'User-Agent: Mozilla/5.0 (X11;Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/39.0.2171.65Chrome/39.0.2171.65 Safari/537.36' -H 'Content-Type:application/x-www-form-urlencoded' -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H'Cache-Control: max-age=0' -H 'Referer:http://uk.mouser.com/ProductDetail/Cree-Inc/CGHV96100F2/?qs=sGAEpiMZZMvplms98TlKY6zbNRoARcUg8gg333Al6-H 'Connection: keep-alive' --data'__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=skTHKc%2BTu8q1ptksBWazoqW1jH%2F9s30wKeqLaG6vPBO92Ae4BJFGniiNMJOdrxMC0BKNq0OgMPn9jzXyEnh%2BhZElrKrDDEwTj6wDz%2BB5Mc8596z13lM4bwTtSkhsckjY87ZWffCEhuwhyb5YCmSMivmI453lwnERDa8eObcoNnPPaM0TNaN0oX6eY%2FQ0eiyT%2FJsDR6vWe4u1sV0sPkLebGRRWfI4chXx3bL9X0CXPlXzEjYBjSMVFvahuPicHdxN4QG31f8teVRA4a6JqwXeveNQi8J4yp2Euq3lgQnEjPAWpjeUEq5tXJbII8qczxQBrYBFu7ebLbylPNsPfrOeY6REXhUiEV1...

That's how ugly. Those ellipses (...) stand for 5000 characters of ASP __VIEWSTATE parameter omitted. What ungodly process would result in something like this being sent from my browser? Oh it's just the Mouser site. But none of the other sites are much better in that regard.

Much of my time was spent in the Chrome and Firefox debugging tools figuring out what convoluted requests I needed to construct to make the sites do what I wanted.

My most advanced weapon was the Tamper Data extension which allows you to intercept all the requests your browser sends, modify any of their data and then send them on their way again. This way I could find out, yes I need all those 5000 characters in the ASP __VIEWSTATE parameter or the requests would fail.

These demons aside I managed to successfully figure out how to add items to Mouser, Digikey, Farnell, Newark and RS Components. I thought that it's a start at least. If you use Chrome or Firefox, you can download and install the latest version of these efforts here.

If you are interested more in the development of the extension you should check out this short presentation from FOSDEM and of course peruse the source-code at your leisure.

Discussions

Jarrett wrote 05/25/2016 at 16:52 point

Fiddler is also a pretty fantastic tool, if you haven't tried it.

  Are you sure? yes | no

Kaspar Emanuel wrote 05/25/2016 at 17:19 point

Hadn't heard of it., thanks very much for the tip. 

  Are you sure? yes | no