我想连接'http://exo.smtown.com/Board/List/10724'或'http://exo.smtown.com/Board/List/?kind=1'(这些页面在同一页面上)。
当我连接页面时,加载的内容就像'http://exo.smtown.com/Error/404.htm?aspxerrorpath=/Bo'
如何连接页面而不是错误页面?
//doc = Jsoup.connect("http://exo.smtown.com/Board/List/10724").get();
doc = Jsoup.connect("http://exo.smtown.com/Board/List/?kind=1").get();
contents = doc.select("div");
String temp = contents.text();
Log.d("logg0","temp: "+temp);
我希望输出'SM STAR Home ....',但是实际输出是'페이지를없습니다....'
+ 我尝试过
protected Object doInBackground(Object[] params) {
try {
doc = Jsoup.connect("http://exo.smtown.com/Board/List/?kind=1").timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com").get();
contents = doc.select("div");
} catch (Exception e) {
e.printStackTrace();
}
String temp = contents.text();
Log.d("logg0","temp: "+temp);
+ 也尝试过
doc = Jsoup.connect("http%3A%2F%2Fexo.smtown.com%2FBoard%2FList%2F10724").get();
答案 0 :(得分:0)
您需要对URL进行编码。
URLEncoder.encode(stringToBeEncoded, "UTF-8")
在您的情况下:
Document gDoc = JSoup.connect(placesURL.format(URLEncoder.encode("http://exo.smtown.com/Board/List/?kind=1", "UTF-8"))
答案 1 :(得分:0)
尝试
try {
Jsoup.connect("http://exo.smtown.com/Board/List/?kind=1")) / required URL
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com").get()
.select("div")
.ownText();
}catch (Exception e) {
//handle exception
}
希望有帮助