简体   繁体   English

jsoup 有问题

[英]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?我正在尝试通过在谷歌中搜索来获取图像,我正在使用 jsoup,一切都很好,我可以获取图像,但它们的质量非常低,还有另一种方法可以使它们更好质量?

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.试图在目标站点上找到相同的图像非常困难,并且需要搜索整个站点、获取所有图像并找出哪一张看起来像邮票。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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