Reassembling URLs from Files

As your groups have begun drafting essays for our final product, some of you have asked me how to figure out how to recompose the permalink to a Texas ad using the information in the ad’s txt filename. Here’s a quick tutorial.

First, open your plain text editor (TextWrangler, Notepad, etc.) and paste this into your window:

http://texashistory.unt.edu/ark:/

That’s how every permalink begins. Now copy the filename of the ad you are interested in onto the second line, for example:

 TX_18501221_Gazette_67531-metapth80961-m1-7-6078.5-1168.5

Next, delete everything in that line from the last underscore to the beginning of the line, so you are left with this:

 67531-metapth80961-m1-7-6078.5-1168.5

Now, use your “find and replace” function to replace all the hyphens (‘-‘) with a forward slash (‘/’), so you get this:

 67531/metapth80961/m1/7/6078.5/1168.5

Join your two lines together, and you are pretty close to your URL. The only thing you need to fix is the end. The two final numbers are the lat and lon values, so you need to remove the final forward slash and instead format those numbers like this:

http://texashistory.unt.edu/ark:/67531/metapth80961/m1/7/?zoom=5&lat=6078.5&lon=1168.5

In other words, what comes before the penultimate number is ?zoom=5&lat=, and what comes between the two last numbers (where your final forward slash was) is &lon=. Put it all together and you have your URL!

Comments are closed.