AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
### 1.载入文件 从URL加载文档,使用`Jsoup.connect()`方法从URL加载HTML。 ``` public static void main(String[] args) throws IOException{ try { Document document = Jsoup.connect("https://trustie.educoder.net").get(); //String title=document.title(); System.out.println(document.title()); //System.out.println(document); } catch (IOException e) { e.printStackTrace(); } } ``` ### 2.从文件加载文档 使用`Jsoup.parse()`方法从文件加载HTML。 ``` public static void main(String[] args) throws IOException{ try { Document document = Jsoup.parse( new File( "C:\\Users\\Administrator\\Desktop\\1.html" ) , "utf-8" ); System.out.println(document.title()); System.out.println(document); } catch (IOException e) { e.printStackTrace(); } } ``` ### 3.从String加载文档 使用`Jsoup.parse()`方法从字符串加载HTML。 ``` public static void main(String[] args) throws IOException{ String html = "<html><head><title>First parse</title></head>" + "<body><p>this is number</p></body></html>"; Document document = Jsoup.parse(html); System.out.println(document); } ```