Sept 15th, 2017 Update: Amazon recently made a slight tweak to their Merch pages that broke the existing uploader. You can download the latest version of Merchpy which has fixed this issue.
Uploading shirts to Merch By Amazon is a giant pain in the ass and a tedious manual process. I set out to automate as much of the process as possible so that either a.) much of the work could be outsourced without having to hand over your Amazon credentials to someone or at least b.) all of the button pressing on the website could be automated.
The result is something I’m calling MerchPy. I made this for myself and figured others could benefit from it as well, so I’m releasing it for free, open source, with no warranty or guarantee that this will work for you as well.
MerchPy is a rather quickly hacked-together Python script that automates much of the Merch upload process. The script relies on you entering all the shirt upload information into a .CSV file, which it then uses to fill out the forms on the Merch website as it navigates the pages.
Let’s get into how you can install and run MerchPy.
This script will require –
- Python (a programming and scripting language)
- Selenium (a web browser automation toolkit)
- Google Chrome (the web browser I chose to use in the script – you may be able to modify the script to use a different browser if you’re technical)
- Chrome Selenium Driver (lets Selenium interact nicely with Chrome)
This script was made using Windows and my install instructions will assume you’re using Windows as well. If you’re using a different operating system, you’ll still need all of these requirements but I’ll assume you’re smart enough to figure out how to find and install your own OS-specific versions.
Here are the steps you need to do in order to run this script –
- Install Python. This was made with Python 3.6.1, but any Python 3.x version should work.
- Be sure to click this checkbox to add Python to PATH, otherwise some of the next steps won’t work.
- Install Selenium for Python by doing the following after Python in installed –
- Open up the command window (Press Windows + R, type in “cmd”, click OK), and type the following without quotes – “pip install selenium”
- If the above step gives you a permission error, you need to run the command prompt as an admin. The easiest way to do this is search for “cmd” using Cortana/Windows search, right click, and “Run as Administrator”
- Install the latest version of Chrome if you don’t have it already.
- Download the MerchPy zip file from GitHub. Unarchive the zip file, rename it to “MerchPy” if you’d like (I’ll assume you did as I continue).
- Download the latest version of the Selenium Chrome Driver. This will download a .zip file, extract the .exe inside of the file and place it in the MerchPy folder.
That wraps up everything you need in order to run the script – now lets talk about setting up the data.
The Quick Setup Guide
The merchpy.csv file is critical to the script running correctly. Here’s what the file looks like with a sample row included, opened in both Excel and a text editor.
Here are the quick steps to the rest of the setup –
- Enter your Merch login credentials into the first row of the “merchpy.csv” file (optional, see below).
- Enter your shirt data into rows 3+ of the “merchpy.csv” file – use the template in row 3 as an guide.
- Place all your png files into the MerchPy directory, making sure the file names match their corresponding rows in the csv file.
- By default, the script is set up to run 10 shirts at a time, which matches my daily limit. You can modify this number by editing the merch.py file and changing the line near the top that says “daily_limit = 10” to whatever number you wish. If you choose a number higher than your daily limit, shirts will be uploaded as “drafts” instead of being published live once you hit your maximum.
- Run the “merch.py” script. The easiest way to do this is to go to your MerchPy directory, hold Shift and right click in a blank space. You should have an option like “Open Powershell window here” or “Open command window here”. Once that window opens, type “py merch.py” and hit enter.
- When the script in finished running, it will move completed shirt entries into the”completed/completed.csv” file. It will move the completed PNG files into the completed folder as well.
If you want a more detailed explanation of the steps, read on.
Setting Up the CSV File to Run
The first step is adding your shirt and login data into the merchpy.csv file that is inside your MerchPy folder.
First, a word on CSV files. CSV stands for “comma separated values”. It’s a way to format data into a format that the script can easily read to tell each data element apart (for example, where your shirt title ends and your shirt description begins). MerchPy comes with a CSV file called “merchpy.csv”. You need to use the exact format that’s given by this file, or else the script will fail to work. Don’t add extra values to the rows, simply edit the data between the commas as needed. If there are commas within your values, you need to place the entire value between quotes, like this – ,”black, white, pink”,
You can create and edit a CSV file using a variety of different programs – the most popular being Microsoft Excel, or a plain old text editor like Notepad. I’d recommend using a text editor, as Excel can mess the data up if you’re not careful (for example, converting “…” to the special character “…” which Merch won’t accept). Also, Excel won’t show that it put quotes in a list like the colors example above. Look again at the below screenshots of the same exact file, and how you only see the quotes in the text editor version.
Let’s take a look at the data you can enter, starting with your login data. The first row looks like this –
Merch Email:,firstname.lastname@example.org,Merch Password:,replace me,,,,,,
You can replace the “email@example.com” with your Merch email address and the “replace me” with your Merch password, and the script will automatically log you in. If you don’t like the idea of putting your credentials into the file, you don’t have to. Instead, remove the data from those fields and leave them empty so it looks like this –
Merch Email:,,Merch Password:,,,,,,,
If you do this, you’ll need to manually log in when you see the browser get to the login page. If you don’t log in, the script will exit after a minute or so.
When it comes to the shirt data you need to enter into the csv, here’s a list of accepted values for each field. An asterisk (*) indicates a required field – not entering data will result in the script exiting.
- Shirt Type* – “anvil” or “premium”.
- Brand Name* – Brand name field for your shirt.
- Shirt Title* – Listing title for your shirt, I believe the maximum is 60 characters. If you enter anything beyond that it will be truncated.
- Desc 1 – The first “key product feature” field on the shirt description page.
- Desc 2 – The second “key product feature” field on the shirt description page.
- Colors* – list out any colors you want, up to 5 and at least 1. The colors must be like the following format, separated by commas and enclosed in quotes if you have more than one color selected – “black, dark heather, navy, baby blue, asphalt”. Use the same exact color name as what they use when you hover over a color on the Merch page. They include – dark heather, heather grey, heather blue, black, navy, silver, royal blue, brown, slate, red, asphalt, grass, olive, kelly green, baby blue, white, lemon, cranberry, pink, orange, purple.
- Fits* – Select one or more “fit type” – mens, womens, kids. If selecting one or more, they must be enclosed in quotes and separated by commas just like the colors, e.g. “mens, womens, kids”.
- Price* – Enter a valid price, must be formatted with a decimal and two trailing digits for cents like “13.99”, “20.00”, etc.
- Shirt File Name* – name of the shirt file that is in the MerchPy directory. Must end in “.png”.
- Desc – for the long-form shirt description field. This can be empty, but if you enter any text then there must be 75 or more characters, with an upper limit of 2000.
Once you have your files in place and your spreadsheet filled out with the correct data, you’re ready to run the script. Open a command window and navigate to your MerchPy directory. The easy way to do this is to hold Shift and right-click on your MerchPy directory and then select “Open Powershell window here” or “Open command window here”.
Once that opens, type in “py merch.py” and press enter. A new Chrome window should appear and navigate to Merch by Amazon. When you see the login screen, if you didn’t enter your login credentials into the csv file, you need to login here. Once that is done, assuming your files are all in place and your csv data is good, it should go through and upload all of your shirts!
This is admittedly a very fragile process with a lot of chances for failure. Issues could include slowness on the Merch server causing the script to time out, bad data in your CSV file, corrupt or missing image files, and more.
Many errors have been handled for, and you should receive an explanation in your command window as to why the script stopped early if it was something like missing data in your CSV file. In these cases you need to fix the data and run the script again. Any shirts that were uploaded before the error should have been moved from the file into the completed.csv file as well as had the .png moved to the completed folder.
If you receive a more verbose Python error message, there could be a variety of issues. The most common is that Selenium couldn’t move forward to the next step due to an error on the web page. Reading through the error message (particularly near the bottom) might give you some insight into why it failed.
If you’d like my help in figuring the issue out, please leave a comment on this page so others can benefit from the help as well.
If you’re a programmer and you’d like to help improve Merchpy, feel free to submit improvements to the MerchPy github.
Amazon may or may not see this uploading script as a bannable offense to your account. Use at your own risk. Given that the tool clicks around elements of the webpage exactly how a real user does, as far as I know it should be indistinguishable from their side if it’s a user doing the upload or the script doing the upload.