關於Jsoup 僞裝請求頭

public static void main(String[] args) throws MalformedURLException, IOException {
//      Document parse = Jsoup.parse(new URL("http://info.bet007.com/cn/team/Summary.aspx?TeamID=35"), 10000);
//      Document parse = Jsoup.parse(new URL("http://www.baidu.com"), 10000);
        Connection connect = Jsoup.connect("http://info.bet007.com/cn/team/Summary.aspx?TeamID=35");
        Map<String, String> header = new HashMap<String, String>();
        header.put("Host", "http://info.bet007.com");
        header.put("User-Agent", "  Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0");
        header.put("Accept", "  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
        header.put("Accept-Language", "zh-cn,zh;q=0.5");
        header.put("Accept-Charset", "  GB2312,utf-8;q=0.7,*;q=0.7");
        header.put("Connection", "keep-alive");
        Connection data = connect.headers(header);
        Document document = data.get();

        System.out.println(document.html());
    }
已修正,感謝 喜歡聽歌的程序員 的批評指正
發佈了46 篇原創文章 · 獲贊 33 · 訪問量 33萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章