通过扫描仪和;使用java的元素

通过扫描仪和;使用java的元素,java,web-scraping,Java,Web Scraping,此代码旨在爬网到 我想获取此字符串(品牌)的所有链接,或包含此字符串的所有链接 品牌的型号名称(型号)也是如此 最后,通过(品牌和型号)获取手表的价格 到目前为止,我正在尝试检查获取的链接是否包含字符串(Brand) 代码运行良好 但是它没有给我链接 公共级蜘蛛腿 { 专用静态最终int最大深度=2 私有哈希集链接 公共蜘蛛腿 { } } links = new HashSet<>(); if ((!links.contains(URL) && (depth &l

此代码旨在爬网到

我想获取此字符串(品牌)的所有链接,或包含此字符串的所有链接

品牌的型号名称(型号)也是如此

最后,通过(品牌和型号)获取手表的价格

到目前为止,我正在尝试检查获取的链接是否包含字符串(Brand)

代码运行良好

但是它没有给我链接

公共级蜘蛛腿

{

专用静态最终int最大深度=2

私有哈希集链接

公共蜘蛛腿

{

}

}

links = new HashSet<>();
if ((!links.contains(URL) && (depth < MAX_DEPTH))) 




{




    System.out.println(">> Depth: " + depth + " [" + URL + "]");




    try {




        links.add(URL);




        Document document = Jsoup.connect(URL).get();




        if(document.select("href").toString().contains(Brand) )




        {




            Elements linksOnPage = document.select("a[href]");


        

            depth++;




            for (Element page : linksOnPage) 




            {




                getPageLinks(page.attr("abs:href"), depth, Brand , Model);




            }




        }




    } catch (IOException e) {




        System.err.println("For '" + URL + "': " + e.getMessage());




    }




}
Scanner sc= new Scanner(System.in);   




System.out.print("Enter a Brand: ");  




String str= sc.nextLine();




System.out.print("Enter a Model: ");




String btr= sc.nextLine();




new Spiderleg().getPageLinks("https://www.chrono24.com/", 0 , str , btr);