当我在jsoup中使用带有波斯字符的URL时,我得到了这个例外 我从浏览器的地址栏中复制了网址 代码:
String url = "http://www.tahlildadeh.com/%D8%A2%D9%85%D9%88%D8%B2%D8%B4/%D8%A2%D9%85%D9%88%D8%B2%D8%B4-%DA%AF%D8%A7%D9%85-%D8%A8%D9%87-%DA%AF%D8%A7%D9%85-%D8%A7%D9%86%D8%AF%D8%B1%D9%88%DB%8C%D8%AF";
Document document = Jsoup.connect(url).data("query", "Java")
.userAgent("...")
.timeout(10000)
.post();
System.out.println(document.title());
异常:
Exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=404, URL=http://www.tahlildadeh.com/%25d8%25a2%25d9%2585%25d9%2588%25d8%25b2%25d8%25b4/%25d8%25a2%25d9%2585%25d9%2588%25d8%25b2%25d8%25b4-%25da%25af%25d8%25a7%25d9%2585-%25d8%25a8%25d9%2587-%25da%25af%25d8%25a7%25d9%2585-%25d8%25a7%25d9%2586%25d8%25af%25d8%25b1%25d9%2588%25db%258c%25d8%25af
问题是异常中的实际url和url是不同的,当我用浏览器打开该链接时,我得到404错误。