Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java PC中的URL源代码不';在电话HTTP中不匹配_Java_Html_Http_Twitter - Fatal编程技术网

Java PC中的URL源代码不';在电话HTTP中不匹配

Java PC中的URL源代码不';在电话HTTP中不匹配,java,html,http,twitter,Java,Html,Http,Twitter,使用此URL: 当我在我的PC网络浏览器中检查视图源时,我可以找到og:type like <meta property="og:title" content="CNN on Twitter"> Web服务器可以为不同的用户代理提供不同的内容。那么,有没有什么技巧可以使我的电话输入流代理与PC代理中的相同?没有什么技巧。在创建URLConnection时,可以传递所有类型的头。 String urlContent = ""; try { Syste

使用此URL:

当我在我的PC网络浏览器中检查视图源时,我可以找到og:type like

<meta  property="og:title" content="CNN on Twitter">

Web服务器可以为不同的用户代理提供不同的内容。那么,有没有什么技巧可以使我的电话输入流代理与PC代理中的相同?没有什么技巧。在创建
URLConnection
时,可以传递所有类型的头。
    String urlContent = "";
    try {
        System.out.println("I'm trying to connect");

        URL urlCon = new URL(urlStr);

        HttpURLConnection con = (HttpURLConnection) urlCon
                .openConnection();
        System.out.println("Ok im here ");
        con.setReadTimeout(6000);

        if (con.getResponseCode() == 200) {
            System.out.println("Page is ok!");

            urlContent = readStream(con.getInputStream());


            return urlContent;

        } else {
            return urlContent;
        }
    } catch (UnknownHostException e){
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return urlContent;
}