HttpURLConnection 和HttpClient+Jsoup处理标签抓取页面和模拟登录

本文主要是介绍HttpURLConnection 和HttpClient+Jsoup处理标签抓取页面和模拟登录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

HttpURLConnection抓取

package com.app.html;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class Html {
    private static final String loginURL = "http://login.goodjobs.cn/index.php/action/UserLogin";
    private static final String forwardURL = "http://user.goodjobs.cn/dispatcher.php/module/Personal/?skip_fill=1";
    
    /**
     * 获取登录页面请求
     * @param loginUrl登录URL
     * @param params登录用户名/密码参数
     * @throws Exception
     */
    public static String  createHtml(String...params)throws Exception{
        URL url = new URL(loginURL);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setDoOutput(true);
        loginHtml(conn, params);
        return forwardHtml(conn,url);
    }
    /**
     * 登录页面
     * @param conn
     * @param params登录用户名/密码参数
     * @throws Exception
     */
    private static void loginHtml(HttpURLConnection conn, String... params)
            throws Exception {
        OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream(), "GBK");
        StringBuffer buff=new StringBuffer();
        buff.append("memberName="+URLEncoder.encode(params[0], "UTF-8"));//页面用户名
        buff.append("&password="+URLEncoder.encode(params[1],"UTF-8"));//页面密码
        out.write(buff.toString());//填充参数
        out.flush();
        out.close();
    }
    /**
     * 转向到定向的页面
     * @param conn连接对象
     * @param url重新定向请求URL
     * @param toUrl定向到页面请求URL
     * @throws Exception
     */
    public static String forwardHtml(HttpURLConnection conn,URL url)throws Exception{
        //重新打开一个连接
        String cookieVal = conn.getHeaderField("Set-Cookie");
        url = new URL(forwardURL);
        conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.setRequestProperty("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Foxy/1; .NET CLR 2.0.50727;MEGAUPLOAD 1.0)");
        conn.setFollowRedirects(false);//置此类是否应该自动执行 HTTP 重定向
        // 取得cookie,相当于记录了身份,供下次访问时使用
        if (cookieVal != null) {
            //发送cookie信息上去,以表明自己的身份,否则会被认为没有权限
            conn.setRequestProperty("Cookie", cookieVal);
        }
        conn.connect();
        InputStream in = conn.getInputStream();
        BufferedReader buffReader = new BufferedReader(    new InputStreamReader(in,"GBK"));
        String line = null;
        String content = "";
        while ((line = buffReader.readLine()) != null) {
            content +="\n" +line;
        }
        //IOUtils.write(result, new FileOutputStream("d:/index.html"),"GBK");
        write(content, "d:/forward.html");
        buffReader.close();
        return content;
    }
    
    /**
     *
     * @param content
     * @param htmlPath
     * @return
     */
     public static boolean write(String content, String htmlPath) {
            boolean flag = true;
            try {
                Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlPath), "GBK"));
                out.write("\n" + content);
                out.close();
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
                return false;
            } catch (UnsupportedEncodingException ex) {
                ex.printStackTrace();
                return false;
            } catch (IOException ex) {
                ex.printStackTrace();
                return false;
            }
            return flag;
        }
    
    
    public static void main(String[] args)throws Exception{
        String [] params={"admin","admin12"};
        System.out.println(createHtml(params));
    }
}

 HttpClient抓取页面 未处理样式的

package com.app.html;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;

public class HttpClientHtml {
    private static final String SITE = "login.goodjobs.cn";
    private static final int PORT = 80;
    private static final String loginAction = "/index.php/action/UserLogin";
    private static final String forwardURL = "http://user.goodjobs.cn/dispatcher.php/module/Personal/?skip_fill=1";
    
    /**
     * 模拟等录
     * @param LOGON_SITE
     * @param LOGON_PORT
     * @param login_Action
     * @param params
     * @throws Exception
     */
    private static HttpClient loginHtml(String LOGON_SITE, int LOGON_PORT,String login_Action,String ...params) throws Exception {
        HttpClient client = new HttpClient();
        client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
        // 模拟登录页面
        PostMethod post = new PostMethod(login_Action);
        NameValuePair userName = new NameValuePair("memberName",params[0] );
        NameValuePair password = new NameValuePair("password",params[1] );
        post.setRequestBody(new NameValuePair[] { userName, password });
        client.executeMethod(post);
        post.releaseConnection();
        // 查看cookie信息
        CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
        Cookie[] cookies = cookiespec.match(LOGON_SITE, LOGON_PORT, "/", false,
                client.getState().getCookies());
        if (cookies != null)
            if (cookies.length == 0) {
                   System.out.println("Cookies is not Exists ");
            } else {
                for (int i = 0; i < cookies.length; i++) {
                    System.out.println(cookies[i].toString());
                }
            }
        return client;
    }
    /**
     * 模拟等录 后获取所需要的页面
     * @param client
     * @param newUrl
     * @throws Exception
     */
    private static void createHtml(HttpClient client, String newUrl)
            throws  Exception {
        PostMethod post = new PostMethod(newUrl);
        client.executeMethod(post);
        post.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "GBK");
        String content= post.getResponseBodyAsString();
        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
        //IOUtils.write(content, new FileOutputStream("d:/"+format.format(new Date())+".html"),"GBK");
        write(content,"d:/"+format.format(new Date())+".html");
        post.releaseConnection();
    }
 
    
    
    public static void main(String[] args) throws Exception {
        String [] params={"admin","admin123"};
        HttpClient client = loginHtml(SITE, PORT, loginAction,params);
        // 访问所需的页面
        createHtml(client, forwardURL);
     
        //System.out.println(UUID.randomUUID());
    }
    
    
    /**
     *
     * @param content
     * @param htmlPath
     * @return
     */
     public static boolean write(String content, String htmlPath) {
            boolean flag = true;
            try {
                Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlPath), "GBK"));
                out.write("\n" + content);
                out.close();
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
                return false;
            } catch (UnsupportedEncodingException ex) {
                ex.printStackTrace();
                return false;
            } catch (IOException ex) {
                ex.printStackTrace();
                return false;
            }
            return flag;
        }
}


HttpClient抓取页面处理样式的页面效果(连接服务器站点的css)

package com.app.html;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.app.comom.FileUtil;

public class HttpClientHtml {
    private static final String SITE = "login.goodjobs.cn";
    private static final int PORT = 80;
    private static final String loginAction = "/index.php/action/UserLogin";
    private static final String forwardURL = "http://user.goodjobs.cn/dispatcher.php/module/Personal/?skip_fill=1";
    private static final String toUrl = "d:\\test\\";
    private static final String css = "http://user.goodjobs.cn/personal.css";
    private static final String Img = "http://user.goodjobs.cn/images";
    private static final String _JS = "http://user.goodjobs.cn/scripts/fValidate/fValidate.one.js";
    /**
     * 模拟等录
     * @param LOGON_SITE
     * @param LOGON_PORT
     * @param login_Action
     * @param params
     * @throws Exception
     */
    private static HttpClient loginHtml(String LOGON_SITE, int LOGON_PORT,String login_Action,String ...params) throws Exception {
        HttpClient client = new HttpClient();
        client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
        // 模拟登录页面
        PostMethod post = new PostMethod(login_Action);
        NameValuePair userName = new NameValuePair("memberName",params[0] );
        NameValuePair password = new NameValuePair("password",params[1] );
        post.setRequestBody(new NameValuePair[] { userName, password });
        client.executeMethod(post);
        post.releaseConnection();
        // 查看cookie信息
        CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
        Cookie[] cookies = cookiespec.match(LOGON_SITE, LOGON_PORT, "/", false,
                client.getState().getCookies());
        if (cookies != null)
            if (cookies.length == 0) {
                   System.out.println("Cookies is not Exists ");
            } else {
                for (int i = 0; i < cookies.length; i++) {
                    System.out.println(cookies[i].toString());
                }
            }
        return client;
    }
    /**
     * 模拟等录 后获取所需要的页面
     * @param client
     * @param newUrl
     * @throws Exception
     */
    private static String  createHtml(HttpClient client, String newUrl) throws  Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String filePath = toUrl    + format.format(new Date() )+ "_" + 1 + ".html";
        PostMethod post = new PostMethod(newUrl);
        client.executeMethod(post);
        //设置编码
        post.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "GBK");
        String content= post.getResponseBodyAsString();
        FileUtil.write(content, filePath);
        System.out.println("\n写入文件成功!");
        post.releaseConnection();
        return filePath;
    }
    /**
     * 解析html代码
     * @param filePath
     * @param random
     * @return
     */
    private static String JsoupFile(String filePath, int random) {
        
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        File infile = new File(filePath);
        String url = toUrl + format.format(new Date()) + "_new_" + random+ ".html";
                
        try {
            File outFile = new File(url);
            Document doc = Jsoup.parse(infile, "GBK");
            String html="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
            StringBuffer sb = new StringBuffer();
            sb.append(html).append("\n");
            sb.append("<html>").append("\n");
            sb.append("<head>").append("\n");
            sb.append("<title>欢迎使用新安人才网个人专区</title>").append("\n");
            Elements meta = doc.getElementsByTag("meta");
            sb.append(meta.toString()).append("\n");
            
            body//
            Elements body = doc.getElementsByTag("body");
            
            link//
            Elements links = doc.select("link");//对link标签有href的路径都作处理
            
            for (Element link : links) {
                String hrefAttr = link.attr("href");
                if (hrefAttr.contains("/personal.css")) {
                    hrefAttr = hrefAttr.replace("/personal.css",css);
                    Element hrefVal=link.attr("href", hrefAttr);//修改href的属性值
                    sb.append(hrefVal.toString()).append("\n");
                }
            }
            script//
            Elements scripts = doc.select("script");//对script标签
            for (Element js : scripts) {
                String jsrc = js.attr("src");
                if (jsrc.contains("/fValidate.one.js")) {
                    String oldJS="/scripts/fValidate/fValidate.one.js";//之前的css
                    jsrc = jsrc.replace(oldJS,_JS);
                    Element val=js.attr("src", jsrc);//修改href的属性值
                    sb.append(val.toString()).append("\n").append("</head>");
                }
            }
            
            script//
            Elements tags = body.select("*");//对所有标签有src的路径都作处理
            for (Element tag : tags) {
                String src = tag.attr("src");
                if (src.contains("/images")) {
                    src = src.replace("/images",Img);
                    tag.attr("src", src);//修改src的属性值
                }
            }

            sb.append(body.toString());
            sb.append("</html>");
            
            BufferedReader in = new BufferedReader(new FileReader(infile));
            Writer out = new BufferedWriter(new OutputStreamWriter(    new FileOutputStream(outFile), "gbk"));
            String content = sb.toString();
            out.write(content);
            in.close();
            
            System.out.println("页面已经爬完");
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return url;
    }
    
    public static void main(String[] args) throws Exception {
        String [] params={"admin","admin123"};
        HttpClient client = loginHtml(SITE, PORT, loginAction,params);
        // 访问所需的页面
        String path=createHtml(client, forwardURL);
       System.out.println( JsoupFile(path,1));
    }
    
}

 HttpClient抓取页面处理样式的页面效果(从网站下载以txt格式文件写入html处理的css)

package com.app.html;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.app.comom.FileUtil;

public class HttpClientHtml {
    private static final String SITE = "login.goodjobs.cn";
    private static final int PORT = 80;
    private static final String loginAction = "/index.php/action/UserLogin";
    private static final String forwardURL = "http://user.goodjobs.cn/dispatcher.php/module/Personal/?skip_fill=1";
    private static final String toUrl = "d:\\test\\";
    private static final String hostCss  = "d:\\test\\style.txt";
    private static final String Img = "http://user.goodjobs.cn/images";
    private static final String _JS = "http://user.goodjobs.cn/scripts/fValidate/fValidate.one.js";
    /**
     * 模拟等录
     * @param LOGON_SITE
     * @param LOGON_PORT
     * @param login_Action
     * @param params
     * @throws Exception
     */
    private static HttpClient loginHtml(String LOGON_SITE, int LOGON_PORT,String login_Action,String ...params) throws Exception {
        HttpClient client = new HttpClient();
        client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
        // 模拟登录页面
        PostMethod post = new PostMethod(login_Action);
        NameValuePair userName = new NameValuePair("memberName",params[0] );
        NameValuePair password = new NameValuePair("password",params[1] );
        post.setRequestBody(new NameValuePair[] { userName, password });
        client.executeMethod(post);
        post.releaseConnection();
        // 查看cookie信息
        CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
        Cookie[] cookies = cookiespec.match(LOGON_SITE, LOGON_PORT, "/", false,
                client.getState().getCookies());
        if (cookies != null)
            if (cookies.length == 0) {
                   System.out.println("Cookies is not Exists ");
            } else {
                for (int i = 0; i < cookies.length; i++) {
                    System.out.println(cookies[i].toString());
                }
            }
        return client;
    }
    /**
     * 模拟等录 后获取所需要的页面
     * @param client
     * @param newUrl
     * @throws Exception
     */
    private static String  createHtml(HttpClient client, String newUrl) throws  Exception {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String filePath = toUrl    + format.format(new Date() )+ "_" + 1 + ".html";
        PostMethod post = new PostMethod(newUrl);
        client.executeMethod(post);
        //设置编码
        post.getParams().setParameter(HttpMethodParams.HTTP_CONTENT_CHARSET, "GBK");
        String content= post.getResponseBodyAsString();
        FileUtil.write(content, filePath);
        System.out.println("\n写入文件成功!");
        post.releaseConnection();
        return filePath;
    }
    /**
     * 解析html代码
     * @param filePath
     * @param random
     * @return
     */
    private static String JsoupFile(String filePath, int random) {
        
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        File infile = new File(filePath);
        String url = toUrl + format.format(new Date()) + "_new_" + random+ ".html";
                
        try {
            File outFile = new File(url);
            Document doc = Jsoup.parse(infile, "GBK");
            String html="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>";
            StringBuffer sb = new StringBuffer();
            sb.append(html).append("\n");
            sb.append("<html>").append("\n");
            sb.append("<head>").append("\n");
            sb.append("<title>欢迎使用新安人才网个人专区</title>").append("\n");
            Elements meta = doc.getElementsByTag("meta");
            sb.append(meta.toString()).append("\n");
             /本地css
            
            File cssFile = new File(hostCss);
            BufferedReader in = new BufferedReader(new FileReader(cssFile));
            Writer out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(outFile), "gbk"));  
            String content=in.readLine();
            while(content!=null){
                //System.out.println(content);
                sb.append(content+"\n");
                content=in.readLine();
            }
            
            in.close();
            处理body标签//
            Elements body = doc.getElementsByTag("body");
            
            
            处理script标签//
            Elements scripts = doc.select("script");//对script标签
            for (Element js : scripts) {
                String jsrc = js.attr("src");
                if (jsrc.contains("/fValidate.one.js")) {
                    String oldJS="/scripts/fValidate/fValidate.one.js";//之前的css
                    jsrc = jsrc.replace(oldJS,_JS);
                    Element val=js.attr("src", jsrc);//修改href的属性值
                    sb.append(val.toString()).append("\n").append("</head>");
                }
            }
            
            处理所有src的属性值//
            Elements tags = body.select("*");//对所有标签有src的路径都作处理
            for (Element tag : tags) {
                String src = tag.attr("src");
                if (src.contains("/images")) {
                    src = src.replace("/images",Img);
                    tag.attr("src", src);//修改src的属性值
                }
            }

            sb.append(body.toString());
            sb.append("</html>");
            
            out.write(sb.toString());
            in.close();
            
            System.out.println("页面已经爬完");
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return url;
    }
    
    public static void main(String[] args) throws Exception {
        String [] params={"admin","admin123"};
        HttpClient client = loginHtml(SITE, PORT, loginAction,params);
        // 页面生成
        String path=createHtml(client, forwardURL);
        System.out.println( JsoupFile(path,1));
    }
    
}



这篇关于HttpURLConnection 和HttpClient+Jsoup处理标签抓取页面和模拟登录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1021118

相关文章

HTML中meta标签的常见使用案例(示例详解)

《HTML中meta标签的常见使用案例(示例详解)》HTMLmeta标签用于提供文档元数据,涵盖字符编码、SEO优化、社交媒体集成、移动设备适配、浏览器控制及安全隐私设置,优化页面显示与搜索引擎索引... 目录html中meta标签的常见使用案例一、基础功能二、搜索引擎优化(seo)三、社交媒体集成四、移动

HTML input 标签示例详解

《HTMLinput标签示例详解》input标签主要用于接收用户的输入,随type属性值的不同,变换其具体功能,本文通过实例图文并茂的形式给大家介绍HTMLinput标签,感兴趣的朋友一... 目录通用属性输入框单行文本输入框 text密码输入框 password数字输入框 number电子邮件输入编程框

HTML img标签和超链接标签详细介绍

《HTMLimg标签和超链接标签详细介绍》:本文主要介绍了HTML中img标签的使用,包括src属性(指定图片路径)、相对/绝对路径区别、alt替代文本、title提示、宽高控制及边框设置等,详细内容请阅读本文,希望能对你有所帮助... 目录img 标签src 属性alt 属性title 属性width/h

CSS3打造的现代交互式登录界面详细实现过程

《CSS3打造的现代交互式登录界面详细实现过程》本文介绍CSS3和jQuery在登录界面设计中的应用,涵盖动画、选择器、自定义字体及盒模型技术,提升界面美观与交互性,同时优化性能和可访问性,感兴趣的朋... 目录1. css3用户登录界面设计概述1.1 用户界面设计的重要性1.2 CSS3的新特性与优势1.

HTML5 中的<button>标签用法和特征

《HTML5中的<button>标签用法和特征》在HTML5中,button标签用于定义一个可点击的按钮,它是创建交互式网页的重要元素之一,本文将深入解析HTML5中的button标签,详细介绍其属... 目录引言<button> 标签的基本用法<button> 标签的属性typevaluedisabled

电脑提示xlstat4.dll丢失怎么修复? xlstat4.dll文件丢失处理办法

《电脑提示xlstat4.dll丢失怎么修复?xlstat4.dll文件丢失处理办法》长时间使用电脑,大家多少都会遇到类似dll文件丢失的情况,不过,解决这一问题其实并不复杂,下面我们就来看看xls... 在Windows操作系统中,xlstat4.dll是一个重要的动态链接库文件,通常用于支持各种应用程序

SQL Server数据库死锁处理超详细攻略

《SQLServer数据库死锁处理超详细攻略》SQLServer作为主流数据库管理系统,在高并发场景下可能面临死锁问题,影响系统性能和稳定性,这篇文章主要给大家介绍了关于SQLServer数据库死... 目录一、引言二、查询 Sqlserver 中造成死锁的 SPID三、用内置函数查询执行信息1. sp_w

全面解析HTML5中Checkbox标签

《全面解析HTML5中Checkbox标签》Checkbox是HTML5中非常重要的表单元素之一,通过合理使用其属性和样式自定义方法,可以为用户提供丰富多样的交互体验,这篇文章给大家介绍HTML5中C... 在html5中,Checkbox(复选框)是一种常用的表单元素,允许用户在一组选项中选择多个项目。本

Java对异常的认识与异常的处理小结

《Java对异常的认识与异常的处理小结》Java程序在运行时可能出现的错误或非正常情况称为异常,下面给大家介绍Java对异常的认识与异常的处理,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参... 目录一、认识异常与异常类型。二、异常的处理三、总结 一、认识异常与异常类型。(1)简单定义-什么是

Java使用HttpClient实现图片下载与本地保存功能

《Java使用HttpClient实现图片下载与本地保存功能》在当今数字化时代,网络资源的获取与处理已成为软件开发中的常见需求,其中,图片作为网络上最常见的资源之一,其下载与保存功能在许多应用场景中都... 目录引言一、Apache HttpClient简介二、技术栈与环境准备三、实现图片下载与保存功能1.