How to get the product URL from your Amazon affiliate product links

This little trick will show you the quickest way to extract the amazon affiliate product links from the HTML code Amazon presents. This way you can create your own image, or word links that do not look so distracting. This process works on a Macintosh, but could work with any text editor that supports regular expressions. Usually you find these in programmer’s editors. There are tons of free programmer’s editors.

The process I will outline here uses Mac Software, but you could easily do this with Komodo Edit, or any other free editing software.

What You Need

First, you need a piece of software to run the regular expression. I use RegExRX. This is a $5 app you can purchase on the iTunes App store. It is a great little programmers helper that lets you debug regular expressions. It is quick to load and easy to use. You can learn more about it from Mac Technologies Consulting.


Getting the URL

Once you have a piece of software that can run a regular expression 1, then you can get to work.

First, launch your Amazon website logged in as an affiliate. You will need to get your affiliate link.

After you are on the affiliate page, select the Text Only tab, and then the click the Highlight HTML button. Finally, copy (Cmd-C) the highlighted text.

Now extract the URL with RegEx

The key to pulling the Amazon link out of all this code is a small bit of text called a regular expression. The magic instructions are:

href=[\'"]?([^\'" >]+)

I won’t try to explain it here, it’s way too technical. If you are really interested you can find an excellent description at

Next, launch your program that can run a regular expression (RegExRX for me), and then paste in the code above in the search box, then paste in the text from Amazon into the Source Text box. On RegEx RX it looks like this:

Once you have the expression entered, it will highlight the text that is matched. Then you just copy this text and voila! You are ready to create your own links.


If you want to make your own image links, or text links using your Amazon Affiliate id, this is one way to quickly extract the link from the Amazon HTML. Note that this omits the tracking pixel that Amazon likes to include (a one pixel wide image they hide in your page so they can see how many clicks or views you are getting). You affiliate link will work just fine without it, but you lose a little tracking data. If you are not worried about that this process should make it much quicker and easier for you get grab the URL you need without errors.

  1. A regular expression is a bit of programming jargon. It is simply a set of rules that tells a text search engine what bit of text you are searching for in a larger body of text. Think of it as a program that searches for a needle in a haystack.

Published by