连接到我得到的 URL 下面是我得到的 logcat 错误
在此之下,我的代码连接到 url。
当我尝试连接到基本网址http://www.apkmania.co/时,它连接成功
但是当尝试连接到这个 url 时,它会抛出一个错误。
07-31 20:47:20.150: I/System.out(14295): IOException: org.jsoup.HttpStatusException: HTTP error fetching URL. Status=404, URL=http://www.apkmania.co/2013/07/blood-sword-thd-v16-apk.html/
休息;
Thread thread=new Thread(new Runnable(){
public void run(){
PrepareItem(webrss);
runOnUiThread(new Runnable(){
public void run() {
if(dialog.isShowing()){
try {
setDataToHandels();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("SET DATA TO HANDELS: " + e);
}
dialog.dismiss();
}
}
});
}
});
thread.start();
休息;
private void PrepareItem(String url) {
System.out.println(url);
Document content= null;
try {
content = Jsoup.connect(url).userAgent("Mozilla").timeout(10*1000).get();
} catch (final IOException e) {
// TODO Auto-generated catch block
System.out.println("IOException: " + e.toString());
}
int i=0;
try {
Elements html1 = content.getElementById("main-wrapper").getElementsByTag("div").get(16).children();
html1.select("img").first().remove();
String[] main_content= new String[html1.size()];
i=0;
for (Element element_src : html1.select("div")) {
if (element_src.attr("dir").equals("ltr")) {
main_content[i] = element_src.toString();
i++;
}
}
for (int j = 0; j < main_content.length-2; j++) {
all_text = all_text+main_content[j];
}
all_images_ems = html1.select("img");
all_images_src = new String[all_images_ems.size()];
i=0;
for (Element img_src : all_images_ems) {
all_images_src[i] = img_src.attr("src");
i++;
}
anchor_link_ems = html1.select("a");
all_links = new String[anchor_link_ems.size()];
i=0;
for (Element anchor_links : anchor_link_ems) {
all_links[i] = anchor_links.attr("href");
i++;
}
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
请在这方面帮助我。