Jsoup下载错误。说必须登录,但没有登录

时间:2019-02-26 15:46:54

标签: web-crawler jsoup

规格:我公司的服务器运行Jsoup以根据我提供的链接下载pdf

有时我遇到一个问题,即网站上有我可以从浏览器正常下载的文档(pdf或其他格式),但是通过我的抓取软件,它会返回诸如此类的错误

  

出了点问题。不好了!有点不对劲!尝试再次登录。如果您仍然遇到此错误,请通过support@agendapal.com与我们联系。错误描述:MessageInvalid URI:无法解析授权/主机。 TargetSiteVoid CreateThis(System.String,Boolean,System.UriKind)在System.Uri.CreateThis(String uri,Boolean dontEscape,UriKind uriKind)在SWPalInc.WebHost.Controllers.DController.F(String u,String n)在lambda_method( System.Web.Mvc.ReflectedActionDescriptor.Execute的Closure,ControllerBase,Object [])(System的System.Web.Mvc.ControllerActionInvoker的ControllerContext controllerContext,IDictionary 2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary 2个参数)。<> c__DisplayClass15.b__12()。 Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter过滤器,ActionExecutingContext preContext,Func 1 continuation) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList 1过滤器,ActionDescriptor actionDescriptor,IDictionary`2参数)在System.Web.Mvc.ControllerActionActionInvoker.InvokeAction(ControllerContext controllerContext,字符串actionName) System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)处的System.Web.Mvc.MvcHandler处的.Web.Mvc.Controller.ExecuteCore()。System.Web.Mvc处的<> c__DisplayClass6。<> c__DisplayClassb.b__5() .Async.AsyncResul System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()位于System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值和已完成同步) SourceSystem单击此处,然后尝试重新登录

当我尝试使用公司服务器https://meetings.municode.com/d/f?u=https://agendapalncus.blob.core.windows.net/paonia-pubu/MEET-Agenda-e11f135d48564ad983c6c46949e34894.pdf&n=Agenda-Regular%20Town%20Board%20Meeting-February%2026,%202019%206.30%20PM.pdf从此类链接中提取pdf时收到该错误

我尝试使用代理服务器,但是在我对其进行爬网时遇到相同的问题。有人知道这个问题的解决方案吗?

1 个答案:

答案 0 :(得分:1)

当我尝试使用Jsoup解析此URL时,会抛出

Exception in thread "main" org.jsoup.UnsupportedMimeTypeException: Unhandled content type.
Must be text/*, application/xml, or application/xhtml+xml.

因此似乎正在抛出适当的显式异常。尝试捕获并处理此异常。那就是我要用Java做到的方式:

    try {
        doc = Jsoup.connect(url).get();
        (...)
    } catch (UnsupportedMimeTypeException ex) {
        // handle exception here
    }
相关问题