zoukankan      html  css  js  c++  java
  • java http 伪造请求头

    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;
    
    /**
     * Created by Administrator on 2017/6/6.
     */
    public class RefererTest {
        public static void main(String[] args) throws Exception {
            String url = "http://lb.gfstack.geo:8080/OperationProxy/GatewayProxy/text06061532/Text?version=1.0.0&service=TEXT&f=json";
            HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon;)");
            conn.setRequestProperty("referer", "http://www.abc1.com");
            InputStream is = conn.getInputStream();
            StringBuffer sb = new StringBuffer();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String strLine = "";
            while ((strLine = br.readLine()) != null) {
                sb.append(strLine.trim());
            }
            System.out.println(sb.toString());
        }
    }
    

      

  • 相关阅读:
    Struts2异常:HTTP Status 404
    Struts2的Action编写
    Struts2异常:HTTP Status 404
    Struts2的核心配置文件
    Struts2入门1
    Hibernate的批量抓取
    Hibernate检索策略
    Hibernate的HQL多表查询
    Hibernate入门4
    Hibernate异常:MappingException
  • 原文地址:https://www.cnblogs.com/nihaorz/p/6952050.html
Copyright © 2011-2022 走看看