zoukankan      html  css  js  c++  java
  • jsoup抓取网页报错UnsupportedMimeTypeException

      今天在用Jsoup爬虫的时候两次遇到下面错误

    Exception in thread "main" org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=application/json;charset=utf-8, URL=http://qiaoliqiang.cn/Exam/user_login.action
        at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:600)
        at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:540)
        at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:227)
        at cn.qlq.craw.Jsoup.JsoupCookieCraw.login(JsoupCookieCraw.java:51)
        at cn.qlq.craw.Jsoup.JsoupCookieCraw.main(JsoupCookieCraw.java:24)

    第一次:

    代码:

    Response res = connect.method(Method.POST).execute();// 执行请求

    解决办法:

    Response res = connect.ignoreContentType(true).method(Method.POST).execute();// 执行请求

    第二次:

    代码:

            String url = "http://qiaoliqiang.cn/Exam/user_login.action";
            // 直接获取DOM树
            Document document = Jsoup.connect(url).post();

    解决办法:

            // 直接获取DOM树
            Document document = Jsoup.connect(url).ignoreContentType(true).post();
  • 相关阅读:
    从up6-down2升级到down3
    XproerIM产品使用手册
    Web大文件上传控件-asp.net-bug修复-Xproer.HttpUploader6.2
    WordPaster-Chrome浏览器控件安装方法
    poj1009
    poj1012
    poj1016
    poj1019
    poj1023
    poj1026
  • 原文地址:https://www.cnblogs.com/qlqwjy/p/8878185.html
Copyright © 2011-2022 走看看