Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've purchased many an item from Banggood simply because they offer interesting things at low prices. I also am signed up as an affiliate so that I can have an additional funding source for this Blog. One of the annoying things that I've found with their affiliate program is the need to copy each of their advertising banners manually by hand every month. That in fact prevented me from putting their advertising on my Blog, until now.
Update 01-August-2017: This no longer works! Banggood changed their web site and made is forcing everyone to collect banner ad code manually.


This weekend I decided to play around with the Referral Code & Report part of their site to see if I could do something to help getting the banner code a bit easier. With a little bit of JavaScript I was able to automatically extract all of the banner code in one go without having to click through all the screens. Here's how.

Bit of a disclaimer before you continue: use this at your own risk of course. Banggood can change the behaviour of their site at any time, but this works for now at least. The code is completely safe to use, it isn't a hack, it's just using the functions provided by the website already.

You will need an account with Banggood. You will also need to be signed up as an affiliate. Go to the Referral Code & Report and bring up the JavaScript/Development Console in your browser. The referral page looks something like this:
banggood_code1.png


Enter the following into the JavaScript Console and wait for the updated page to finish loading.
 JavaScript
changeShowNum(200);


That changes how many banner ads the site shows to you in one go. The number 200 seemed like a good amount for me, it doesn't actually go up that high, but better to try and show more than having to go through multiple pages.

Next enter the following code:
 JavaScript
selbannerimagesize(13);getBannerlist();




That tells the site to load 728x90 banners. You can tell it to load others e.g. 336x280 if you change that 13 to a 4. Different numbers here correspond to different banner sizes, I didn't try to document them all.

Now that all the banners of the same size have been loaded it's time to extract their codes. Enter the following into the JavaScript Console and run it:
 JavaScript
var s = '\n'; $('.banner_code_list').find('li').each(function(idx, el) { var e = $(el); s += '<a rel="nofollow" href="' + e.find('a').attr('href') + '" target="_blank"><img src="' + e.find('img').attr('src') + '"/></a>\n'; }); console.log(s);


That puts all of the banner code into the console, which you can then select and copy. The approach used here is the same as Banggood does itself so should work identically.
banggood_code2.png


-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.