gpt4 book ai didi

java - Jsoup无法打开html页面

转载 作者:行者123 更新时间:2023-11-30 04:50:39 25 4
gpt4 key购买 nike

我正在尝试使用 JSoup 打开页面。我尝试打开 www.google.com 之类的页面并使用以下方式打印内容:

Document doc = Jsoup.connect("http://www.google.com").get();
System.out.println(doc.text());

输出是:

Google Ricerca Immagini Video Mappe News Shopping Gmail Altro » iGoogle | Cronologia web | Impostazioni | Accedi Italia   Ricerca avanzataStrumenti per le lingue PubblicitàSoluzioni AziendaliTutto su GoogleGoogle.com in English © 2012 - Privacy e Termini

如果我尝试打开我的页面,例如:

http://www.mysite.com/test.php?link=http://www.myothersite.com/test/test1-/10968/try.html?params=65%253A12%257C66%253A2%257C39%253A6%257C72%253A5104&rt=nc&_dmd=1&id=p3286.c0.m14&_vc=1&x=11&param1=p and d&sotto_categoria=_

我得到了IOException:

java.io.IOException: 400 error loading URL http://www.mysite.com/test.php?link=http://www.myothersite.com/test/test1-/10968/try.html?params=65%253A12%257C66%253A2%257C39%253A6%257C72%253A5104&rt=nc&_dmd=1&id=p3286.c0.m14&_vc=1&x=11&param1=p and d&sotto_categoria=_
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:362)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:338)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:136)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:125)

可能是什么问题?有人可以帮助我吗?谢谢!!

最佳答案

我用一个非常简单的方法解决了..只需删除 queryString 中的黑色空格,并将其替换为 - :)

关于java - Jsoup无法打开html页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9913778/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com