Making a BOM (bill of material) for projects and keeping them up to date is really important. But also it is a tedious task that few people enjoy.
In effort to improve workflow when creating new components or updating existing ones, I have create a Python script that will fetch all important data for a component that you might want to use.
This tool has greatly reduced number of alt+tab / copy & paste juggling from my creating/maintaining BOM workflow, and I hope it does the same for you.
How does it work?
You run python script, enter DigiKey URL of the part you want to get data from.
Script will open the provided URL, parse data and fetch information such as Manufacturer, Manufacturer Part Number, DigiKey number and Description.
Shortly you will see fetched data with combination of hotkeys that you can use in ANY WINDOW to copy information to clipboard.
$ # Fetch.py
Please enter DigiKey URL:
>> https://www.digikey.ca/product-detail/en/stmicroelectronics/STM32L496G-DISCO/497-17136-ND/6697038
Manufacturer: STMicroelectronics
Manufacturer PN: STM32L496G-DISCO
Distributor: DigiKey
Distributor PN: 497-17136-ND
Description: DISCOVERY STM32L496 EVAL BRD
---------------------------------------------
--- Use following shortcuts ---
--- (You can use them in any window) ---
---------------------------------------------
CTRL+1 - Copy 'Manufacturer'
CTRL+2 - Copy 'STMicroelectronics'
CTRL+3 - Copy 'Manufacturer Part Number'
CTRL+4 - Copy 'STM32L496G-DISCO'
CTRL+5 - Copy 'Distributor'
CTRL+6 - Copy 'DigiKey'
CTRL+7 - Copy 'Distributor Part Number'
CTRL+8 - Copy '497-17136-ND'
CTRL+9 - Copy Description
-----------------------------------
CTRL+0 - Fetch new Part (ask for new URL)
-----------------------------------
CTRL+Q - Quit
What is nice about it that it has global hotkeys, so you can now switch to your favorite CAD and start using shortcuts to copy info to clipboard and then paste it into a desired field.
For easier access I recommend creating a shortcut to the Fetch.py script instead of running it from console every time, just in case you haven’t already thought of that.
Python Requirements
Script is written for Python 3 but should easily be ported to any other Python version.
I assume that you have Pip installed (instructions here) and for this script to work please install following modules:
Using Pip, you can install all dependencies using pip install -r requirements.txt
,
or if you prefer, manually one by one (dependencies are: requests, clipboard, pypiwin32, lxml, requests)
Room for improvement
This is a quick and dirty script that I needed and ended up creating in 15 min, therefore don’t expect it to be bullet proof.
Nevertheless it is a very nice and practical tool to have and I use it on daily basis.
Currently script is not fetching information from DigiKey urls that have ?keywords=
in them due the way DigiKey is handling search queries (Try disabling JavaScript in your browser and visit the same URL, it will present a “blank” page).
In order to avoid any OS related issues, string is copied into clipboard. It would be nice to have the script emulate keystrokes so it types the string for you.
I would love to hear how you use it, what do you like and what features would you like to see added next.
Source files
As always all source files are available and posted on GitHub.
If you would like to contribute, feel free to submit a pull-request with your modifications.
2019-06-18 Update: Adding headers field to http requests