一 、发请求获取网页内容
 
1.我们将请求ascii表网址,处理数据获取表格中的具体内容 
import org
.springframework
.web
.bind
.annotation
.GetMapping
;
import org
.springframework
.web
.bind
.annotation
.RestController
;
import java
.io
.*
;
import java
.net
.HttpURLConnection
;
import java
.net
.MalformedURLException
;
import java
.net
.URL
;
@RestController
public class SendRequest {
    
    @GetMapping("/todo")
    public String  
getsource() {
        try {
            //建立连接如ascii表网址 我们获取ascii内容并解析
            URL url 
= new URL("http://ascii.911cha.com/");
            HttpURLConnection connection 
= (HttpURLConnection
) url
.openConnection();
            connection
.setDoInput(true);
            connection
.setRe("GET");
            //
            connection
.setRe("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
            InputStreamReader read 
= new InputStreamReader(connection
.getInputStream(), "utf-8");
            //为字符输入流添加缓冲
            BufferedReader br 
= new BufferedReader(read
);
            //读取返回结果
            String data
=br
.readLine();
            while (br
.readLine() != null
) {
                data 
=data
+br
.readLine();
            }
            System
.out
.println(data
);
            // 释放资源
            br
.close();
            read
.close();
            connection
.disconnect();
            return data
;
        } catch (MalformedURLException e
) {
            e
.printStackTrace();
        } catch (IOException e
) {
            e
.printStackTrace();
        }
        return null
;
    }
}
 
得到数据如下
 
周公解梦老黄历天气预报邮编列车时刻表放假安排911查询 回首页 保存到桌面					输入待查字符     ASCII第一次以规范标准的型态发表是在1967年,最后一次更新则是在1986年,至今为止共定义了128个字符,其中33个字符无法显示(这是以现今操作系统为依归,但在DOS模式下可显示出一些诸如笑脸、扑克牌花式等8-bit符号),且这33个字符多数都已是陈废的控制字符,控制字符的用途主要是用来操控已经处理过的文字,在33个字符之外的是95个可显示的字符,包含用键盘敲下空白键所产生的空白字符也算1个可显示字符(显示为空白)。ASCII控制字符二进制十六进制可以显示的表示法0000 000000␀0000 000101␁0000 001002␂0000 001103␃0000 010004␄0000 010105␅0000 011006␆0000 011107␇0000 100008␈0000 100109␉0000 10100A␊0000 10110B␋0000 11000C␌0000 11010D␍0000 11100E␎0000 11110F␏0001 000010␐0001 000111␑0001 001012␒0001 001113␓0001 010014␔0001 010115␕0001 011016␖0001 011117␗0001 100018␘0001 1001