Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Selenium不显示实际的html页面_Java_Selenium_Jsoup - Fatal编程技术网

Java Selenium不显示实际的html页面

Java Selenium不显示实际的html页面,java,selenium,jsoup,Java,Selenium,Jsoup,因此,我将selenium和jsoup结合使用,以获得动态网站的HTML页面。所以我面临的问题是,我使用selenium获得的页面源代码仍然没有被网站更新。所以我在Flipkart上搜索 public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String searchtext = sc.nextLine();

因此,我将selenium和jsoup结合使用,以获得动态网站的HTML页面。所以我面临的问题是,我使用selenium获得的页面源代码仍然没有被网站更新。所以我在Flipkart上搜索

public class Main {

    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        String searchtext = sc.nextLine();
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\test\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        try{
            driver.get("https://www.flipkart.com/search?q=" + searchtext+ "&otracker=search&otracker1=search&marketplace=FLIPKART&as-show=on&as=off");
            String content  = driver.getPageSource();
            Document doc = Jsoup.parse(content);
            Elements link = doc.getElementsByClass("_3BTv9X");
            System.out.println(link);
        }catch (Exception e){
            System.out.println("Error " + e);
        } finally {
            driver.quit();
        }
    }
}
这就是我使用驱动程序的方式。所以我想要产品的图片链接。我使用的类是images类。例如,如果我搜索了面具,这就是我得到的

<div class="_3BTv9X" style="height:280px;width:200px">
 <img class="_1Nyybr _30XEf0" alt="Van Heusen VHMSBRGPH53287" src="https://rukminim1.flixcart.com/image/612/612/k9u8zgw0/mask-respirator/2/k/j/vhmsbrgph53287-van-heusen-original-imafrjnfytwdxfka.jpeg?q=70">
</div>
<div class="_3BTv9X" style="height:280px;width:200px">
 <img class="_1Nyybr" alt="NHR Surgical Face Mask, Anti Pollution, 3 Ply Face Mask with ISO 9001:2015 Certification (Pack of 30) SG-30 Surgical Mask" src="//img1a.flixcart.com/www/linchpin/fk-cp-zion/img/placeholder_9951d0.svg">
</div>

对于上面的产品,我得到了图片的完整链接,下面是Flipkart的基本标志

注意:这只是输出的一小部分。输出实际上包含50多个产品。我只是想表明,有些链接是有效的,有些是无效的

请帮帮我。我现在该怎么办