Reverse image search using Google api -


i trying write java program loop image files in folder and
reverse image search on google (just trying 1 image in question)

i find example below , result give me url preformed reverse image search.
while wondering how can download 1 of image result site.

some things add have read new google api(?) , find allow me search 100/day, hence choose use old version(?) although warn me method deprecated.

import java.io.bufferedreader; import java.io.file; import java.io.ioexception; import java.io.inputstreamreader;  import org.apache.http.httpresponse; import org.apache.http.client.clientprotocolexception; import org.apache.http.client.httpclient; import org.apache.http.client.methods.httppost; import org.apache.http.entity.mime.multipartentity; import org.apache.http.entity.mime.content.filebody; import org.apache.http.entity.mime.content.stringbody; import org.apache.http.impl.client.defaulthttpclient;  public class reverseimagesearch{   public static void main(string args[]){     try {       httpclient client = new defaulthttpclient();       string url="https://www.google.co.in/searchbyimage/upload";       string imagefile="c:\\users\\chan\\desktop\\pixiv29706591.jpg";       httppost post = new httppost(url);        multipartentity entity = new multipartentity();       entity.addpart("encoded_image", new filebody(new file(imagefile)));       entity.addpart("image_url",new stringbody(""));       entity.addpart("image_content",new stringbody(""));       entity.addpart("filename",new stringbody(""));       entity.addpart("h1",new stringbody("en"));       entity.addpart("bih",new stringbody("179"));       entity.addpart("biw",new stringbody("1600"));        post.setentity(entity);       httpresponse response = client.execute(post);       bufferedreader rd = new bufferedreader(new inputstreamreader(response.getentity().getcontent()));                 string line = "";       while ((line = rd.readline()) != null) {         if (line.indexof("href")>0)             system.out.println(line.substring(8));            //problem:            // 1 of result image sites            // , store in pc         }      }catch (clientprotocolexception cpx){       cpx.printstacktrace();     }catch (ioexception ioex){       ioex.printstacktrace();     }  } } 


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -