关于Jsoup 伪装请求头

2020-02-06 13:34:58

android爬虫工具,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());
    }


  • 2019-10-16 21:02:47

    vue中mixins的详细分析一

    混入 (mixins): 是一种分发 Vue 组件中可复用功能的非常灵活的方式。混入对象可以包含任意组件选项。当组件使用混入对象时,所有混入对象的选项将被混入该组件本身的选项。

  • 2019-10-16 21:04:47

    vue中mixins的详细分析二

    当混合里面包含异步请求函数,而我们又需要在组件中使用异步请求函数的返回值时,我们会取不到此返回值,如下: