スキップしてメイン コンテンツに移動

投稿

5月, 2013の投稿を表示しています

Get Original Hi-res image from Zoomable image on Amazon

Some pages in amazon provide images which user can zoom on, like this page. The question is "Where is the original hi-resolution image?". You can easily find the explanation page for how to construct url for original hi-res image. (See this stack overflow page .) In this post I will show you the code snippet for getting original hires imgae from ASIN code. Note!: This method might be unavailable if amazon change the implementation of zoom and hires image url construnction. Code Actually code is nothing special. Just find " DynAPI.addZoomViewer( " . // pattern for extracting image code used for retrieving original image. private static Pattern AMAZON_ZOOM_IMAGE_PATTERN = Pattern.compile("DynAPI\\.addZoomViewer\\(\".+/(.+?)\",\\s*(.+?),\\s*(.+?),\\s*(.+?),\\s*(.+?),\\s*(.+?),.*\\)"); public static String findOriginalZoomImageUrl(String asin, String country) { String url = getAmazonZoomImageWindowUrl(asin, country); try{

Build Get Parameter String from Javascript Object or Map

This is just a quick tips... I think you can easily understand whole thing from the code below. // example data used for get parameters. You can use plain javascript object if you want. var map = ["name1":"value1", "name2":"value2"]; // Ok, let’s build string... var parameters = []; for(var prop in map) { // if the name part (prop) contains the characters to uri encode, // use encodeURIComponent as well for the name part. parameters.push(prop + "=" + encodeURIComponent(map[prop])); } var parametersStr = parameters.join("&");

How to pick up Hi-Resolution Image from Amazon product page

Recently I realized that Amazon offers high resolution photos in some products. I have found the way to extract these hires images. Note Note!: This method might be unavailable in the future because Amazon may not like this kind of hack or change the implementation :P Basic Strategy For example, this page: http://www.amazon.com/Silver-Violin-Nicola-Benedetti/dp/B008CYV046/ If you see the html source of this page, you can find the following json string. var colorImages = {"initial":[{"large":"http://ecx.images-amazon.com/images/I/XXXXXXX.jpg",.... It represents the urls of various size of images. If you would like to see the hi-resolution image, you should pick up the url which is defined in hiRes property. Source Code You know I still like Java, I will show you the simple Java code. I use Jackson for parsing JSon string. import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; imp