Opening urls in python makes baby jesus cry

A thing I’m doing involved a lot of finding websites on search engines and looking at them for some things that are fairly dull, to make the process a little easier and less infuriating I used seoquake to get a polite looking csv file list of the urls to look at again later after all the searches complete. As I am currently looking at playing with csvs and manipulating them I wondered if I could get something to open the links without copy and pasting.

So, having difficulties understanding what format python reads csvs in I moved to attempting lists and dictionaries and getting no where particularly interesting, I tried double ended queue as I understood it as having the potential to recall rows one at a time. Errors abound I got to this, I got to a point of understanding that d[0] printed the last row, rejoicing I tried a script to open it a tab of a browser.

This was the script:

import webbrowser
derp = csv.reader(open(“derp.csv”, ‘rb’), delimiter=” “, quotechar=”|”)
for row in derp:

d = deque(row)

webbrowser.open_new_tab(d[0])

With great joy I saw “true” print in the python shell thing, and then another, and another and with horror realised it was attempting to open all 170 entries. I wandered away to allow chrome to have its merry way with error messages and was wondering if anyone could shed some light as to what happened.

“This seems like a complete waste of time” weeeeeeeeeeeeeeerll, probably not as much as it sounds as I just copied to clipboard the csv without trudging through the searches then used excel to remove duplicates without having to look up to see if I’d already gone to that website.

Advertisements
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

One Response to Opening urls in python makes baby jesus cry

  1. alexwarrior1 says:

    I believe you want to unindent the line webbrowser.open_new_tab(d[0]).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s