简体   繁体   中英

Having problems with jsoup

I'm trying to get an image by searching in google for this i'm using jsoup, and everything is fine, i can get the images, but they're in a very low quality, there is another way to get them with better quality?

public class JsoupTest {

public static void main(String[] args) {
    String userAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36";
    String url = "https://www.google.com/search?site=imghp&tbm=isch&source=hp&q=galan de noche planta&gws_rd=cr";
    List<String> resultUrls = new ArrayList();
    try {
        Document doc = Jsoup.connect(url).userAgent(userAgent).referrer("https://www.google.com/").get();
        Elements elements =  doc.getElementsByTag("img");
        for (Element element : elements) {
            resultUrls.add(element.absUrl("src"));
        }
    resultUrls.forEach(System.out::println);
    } catch (IOException e) {
        e.printStackTrace();
    }
}

}

There is no way to do that.

Google image search used to show the images, but copyright law caused some issues with this; hence they now only host postage stamp sized versions of it, and you have to click through to the site. Trying to find the same image on the target site is very difficult and would involve spidering the entire site, fetching all images, and figuring out which one looks like the postage stamp.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM