关于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-27 11:02:10

    mac不要输入sudo,免密设置

    mac有时候使用终端进行操作,会让输入sudo 并且要输入命令,这要很啰嗦,浪费时间,我们得想办法去掉。

  • 2019-10-27 11:08:11

    Mac系统移到废纸篓的快捷键是什么

    用Windows键盘上的delete键和del键都不能删除文件,那么在Mac系统移到废纸篓的快捷键是什么?答:在移到废纸篓的快捷键组合就是Command + delete,可以将文件删除到废纸篓。清空废纸篓的快捷键是 Command + shift + delete​。

  • 2019-10-29 11:30:12

    Vue路由的$router.back(-1)回退时如何判断有没有上一个路由

    这个函数是这样的,判断当前页面的历史记录是不是小于等于1,如果小于等于1,说明这个页面没有可以返回的上一页,如果没有可以返回的上一页,就给地址栏加上一个goindex=true的参数,这样你从这个页面在往下一个页面跳转在返回,这个参数就一直加上的