Search code examples
androidparsingjsoupgoogle-image-search

JSOUP parse Google images


I want to parse Google Images' links to thumbnails and full pictures with JSOUP in Android. The android part actually isn't important as all I need is selector-syntax. I searched for tutorials or similar questions but couldn't find any valuable information.

To get images the link is https://www.google.com/search?tbm=isch&q=search-string.

Below is screenshot of Chrome's Webkit and you can see the link to thumbnail. If I could just get that it would be a good start to try getting links to full images myself.

Full size screenshot


Solution

  • It would be selecting with "#rg div.rg_di img"

    So for example something like

    Document doc = Jsoup.connect("https://www.google.com/search?tbm=isch&q=search-string")
                .userAgent("Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36")
                .get()
    
    doc.select("#rg div.rg_di img")