Try Python: It’s not too hard

One thing that bugs me is when people act like computer programming isn’t for them. I am not a very good programmer, but I won’t write it off like it’s not helpful to me. Don’t be intimidated. I believe a small amount of Python is appropriate for a large swath of folks.

I have written—really copied and modified— several scripts to use in my work life and my personal life. No one asked me to write them. I use them because they either make me more productive, or they do something kind of cool that I wouldn’t otherwise do.

One thing I have Python scripts for is just doing a lot of automatic Google searches every day. I skim the results manually, but I don’t have to type or paste my searches. I don’t even have to open the tabs.

I just open Miniconda—more on Miniconda in a minute— run a single Python script—and watch my browser tabs fill up with all the Google search results for my specified searches.

Going through all the results, I can quickly see which results are new because they will be blue as opposed to that purple visited-link color. When new results pop up, it’s pretty cool. I just found what I’m looking for.

Here is my code:

import webbrowser

webbrowser.open('https://www.google.com/search?q=Salma+Hayek&tbm=nws')
webbrowser.open('https://www.google.com/search?q=Beyoncé+news&tbm=nws')
webbrowser.open('https://www.google.com/search?q=cats&udm=7')
webbrowser.open('https://www.google.com/search?q=Finger+Puppets+of+Famous+Historical+Figure&udm=28')

The hardest part of this process is having Python installed on your computer and knowing how to run a script. Let me help you to get past those pain points.

One of the easiest ways to get Python at your disposal is to install Miniconda. It is a lightweight, minimal installation of the Conda package manager that includes just the essential components for managing environments and installing Python packages. Don’t worry about any of that. Suffice to say, “It’s cool.”

I am only going to provide simple instructions for Windows. For all other instructions go to the official docs:

Installing Miniconda — Anaconda documentation

Here are my simple instructions for Windows:

  1. Type “cmd” in your Windows Taskbar Search. A black command prompt will open up.
  2. Copy this code, paste it into the command prompt and hit return. It will download the installer into your Downloads folder:
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe --output .\\Downloads\\Miniconda3-latest-Windows-x86_64.exe

Hopefully you know how to check your Downloads folder. It should look something like this:

Downloads folder showing the Miniconda installer inside

Now double-click that bad boy and follow the prompts. I recommend installing it as a regular user (not administrator) and go with defaults.

Type “miniconda” in the Windows Taskbar Search and run the “Anaconda Prompt (miniconda3) App

Hopefully you see something like this:

Miniconda prompt

Congrats, you installed Python. Actually, you installed Miniconda, but Python came along for the ride.

Now you need a Python script to run. I recommend copying the lines from my code above. Paste them into a text document and save as mytest.py

Put this file into the same folder where the Miniconda prompt says you are. In this example, it is C:\Users\YourName

In the Miniconda prompt type “python mytest.py

Hopefully your python script ran. If you used my code, some tabs should have opened in a web browser.

Now that you have a local Python environment (Miniconda3) and a script (mytest.py), you can start grabbing snippets from Stack Overflow, GitHub or wherever and have some fun and frustration.


Discover more from Things I Tried

Subscribe to get the latest posts sent to your email.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *