连字符和Jsoup错误

时间:2015-08-11 09:50:33

标签: java jsoup special-characters

我有一个网络刮刀,我用连字符弄错了。我在网上搜索并看到了很多与连字符有关的错误,但没有明确的方法可以解决这个问题。

以下是代码:

       try{
            int t = 25 * 1000;
            this.jDoc = Jsoup
                    .connect(url)
                    .userAgent(
                            "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0")
                    .maxBodySize(0).timeout(t).get();

        } catch (IOException e) {

            this.jDoc = null;
        }

错误:

crawling url = http://www.wida-handel.de/Oventrop/OventrPumpengr--Regumat-
error url = http://www.wida-handel.de/Oventrop/OventrPumpengr--Regumat-
jsoup error org.jsoup.HttpStatusException: HTTP error fetching URL.      
Status=404, URL=http://www.wida-handel.de/Oventrop/OventrPumpengr--Regumat-

网址无效,我认为错误是由连字符无法理解引起的。

有没有人对此错误的解决方案有任何想法?

1 个答案:

答案 0 :(得分:0)

    Document doc = Jsoup.connect("http://www.wida-handel.de/Oventrop/OventrPumpengr--Regumat-")
                    .userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0")
                    .maxBodySize(0).timeout(t).ignoreHttpErrors(true).get();

结果

enter image description here