java - Jsoup can't open html page Status=-1 -


while connecting url i'm getting below logcat error i'm getting

and below code connect url.

when try connect base url http://www.apkmania.co/ connects

but when try connect url throws me error.

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/ 

break;

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 handels: " + e);                             }                             dialog.dismiss();                         }                     }                 });             }         });         thread.start();  

break;

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;             (element element_src : html1.select("div")) {                 if (element_src.attr("dir").equals("ltr")) {                     main_content[i] = element_src.tostring();                        i++;                 }                            }              (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;             (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;             (element anchor_links : anchor_link_ems) {                 all_links[i] = anchor_links.attr("href");                 i++;             }          } catch (nullpointerexception e) {             // todo auto-generated catch block             e.printstacktrace();         }     } 

please me in regard.

there's slash @ end of url.

http://www.apkmania.co/2013/07/blood-sword-thd-v16-apk.html/

if remove slash @ end, should work.

http://www.apkmania.co/2013/07/blood-sword-thd-v16-apk.html

edit: it's working me this.

string url = "http://www.apkmania.co/2013/07/blood-sword-thd-v16-apk.html"; 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());  } system.out.println(content); 

and i'm getting <!doctype html public "- ...


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -