网络爬虫-URL编码、解码

来源:互联网 发布:全自动打字赚钱软件 编辑:程序博客网 时间:2024/05/22 05:15

Url文字转换

有些网址带的中文参数要经过URL编码才能正常访问获取网页源码
下面是Java编码解码Url的代码

public class test1 {    public static void main(String[] args) throws UnsupportedEncodingException {        String category1 = "直播";        String encoding = URLEncoder.encode(category1, "utf-8");        System.out.println(encoding);        String category2 = URLDecoder.decode(encoding, "utf-8");        System.out.println(category2);    }}
原创粉丝点击