2012-03-28 44 views
1

我試圖用JSoup打開一個頁面。 我試着使用打開頁面像www.google.com和打印內容:Jsoup無法打開html頁面

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) 

可能是什麼問題?有人可以幫助我嗎?謝謝!

回答

2

我在一個非常簡單的方法解決了.. 只是刪除黑色空間中的queryString與- :)

+0

感謝替換它buddy.You拯救我的一天。 – NamingException 2015-10-27 07:12:49