【问题标题】:JSOUP HTTPStatusException 400 errorJSOUP HTTPStatusException 400 错误
【发布时间】:2018-11-14 06:42:37
【问题描述】:

连接到 URL 时出现以下错误

org.jsoup.HttpStatusException: HTTP error fetching URL. Status=400

我使用下面的代码来连接网址

doc = Jsoup.connect("https://dailymed.nlm.nih.gov/dailymed/search.cfm?query=4-Hydroxyphenyl-Pyruvate Dioxygenase Inhibitor&searchdb=class").get();

当我在浏览器中点击 URL 时,它会很好地显示 HTML 内容。

请就可能出现的问题提出建议。

【问题讨论】:

    标签: java jsoup html-parsing


    【解决方案1】:

    使用 %20 对 URL 中的空格进行 URL 编码

    Document doc = Jsoup.connect("https://dailymed.nlm.nih.gov/dailymed/search.cfm?query=4-Hydroxyphenyl-Pyruvate%20Dioxygenase%20Inhibitor&searchdb=class").get();
    

    此问题已在 Jsoup 的 1.7.3 版中得到修复(请参阅 this),因此您可以升级到该版本作为替代方案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-12
      • 1970-01-01
      • 1970-01-01
      • 2014-08-19
      • 1970-01-01
      • 1970-01-01
      • 2016-03-24
      • 1970-01-01
      相关资源
      最近更新 更多