Python for day-to-day tasks: the webbrowser module

Python for day-to-day tasks: the webbrowser module


An initiative at work requires me to analyze a large spreadsheet of data. One of the columns contains a csv-separated list of bugs that I need to take a look at. Normally, this would be a painful job of copying each defect and pasting it in the browser repeatedly. When hundreds of rows needed analysis, each involving multiple defect IDs,  I switched to python to ease my pain.

I knew where to look because of this cute easter-egg in python:

import antigravity

The help text for this module led me to the library, in my case. The webbrowser module imported here showed how easy it is to launch a browser tab by passing a URL from python:

import webbrowser
import hashlib“”)

This was all I need for my job as well. I wrote a 10 line script that basically:

  1. asked the user for input (in my case a comma separated list of defects),
  2. converted the input to a list and stripped unneeded whitespace,
  3. iterated through this list and appended the defect ID to the base URL, and
  4. called the webbrowser module to open the tabs.

The resulting script looks like this:

import webbrowser

bugs=input(‘Paste the list of bugs:n’)

for i,x in enumerate(buglist):

for i in buglist:

And that’s it! A half-dozen tabs open immediately and I can move on to analyzing them. Python has proved to be a boon in my daily job for quick and dirty scripts like this.

Comments are closed.
%d bloggers like this: