gpt4 book ai didi

java - WebClient 类不存在

转载 作者:行者123 更新时间:2023-12-01 17:59:36 27 4
gpt4 key购买 nike

import com.gargoylesoftware.htmlunit.WebClient;

public class Main {
public static void main(String[] args) throws Exception {
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://www.google.com");
}
}

但我收到以下错误:

Error:(6, 9) java: cannot find symbol
symbol: class WebClient
location: class Main

我尝试在网络上搜索该错误。我得到了 404。

最佳答案

上述代码对我有用

import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

import java.io.IOException;


public class Demo {

public static void main(String[] args) throws IOException {

WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://www.google.com");
System.out.println(page.asText());
}
}

gradle依赖

  compile group: 'net.sourceforge.htmlunit', name: 'com.springsource.com.gargoylesoftware.htmlunit', version: '2.6.0'

关于java - WebClient 类不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60659569/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com