groovy,Jsoup, get status code -


i hope can me have been searching didn't find working.

i connecting number of urls list , works fine started getting 404 error on hence want catch error program doesn't terminate , keeps going through list urls.

this error got

org.jsoup.httpstatusexception: http error fetching url. status=404, url=http:nameofthesite 

i using jsoup.connect , error caused in line of code

    document doc= jsoup.connect(countryurl[i2]).timeout(10*1000)                           .useragent("mozilla/5.0 (windows nt 6.0) applewebkit/536.5 (khtml, gecko) chrome/19.0.1084.46 safari/536.5")     .get(); 

how can change code can status code. i've tried connection.response (something found on site solution sort of problem) getting casting error

 connection.response  response= jsoup.connect(countryurl[i2]).timeout(10*1000)                                   .useragent("mozilla/5.0 (windows nt 6.0) applewebkit/536.5 (khtml, gecko) chrome/19.0.1084.46 safari/536.5")             .execute();             int statuscode = response.statuscode();             if(statuscode==200){ 

but following error

groovy.lang.missingmethodexception: no signature of method: static org.jsoup.connection.response() applicable argument types: (org.jsoup.helper.httpconnection$response) values: [org.jsoup.helper.httpconnection$response@c7325ae] possible solutions: respondsto(java.lang.string), respondsto(java.lang.string, [ljava.lang.object;) 

any appreciated, thanks.

there's typo in code:

connection.response response = jsoup.connect(...) ... //         ^ //         | 

response static class (interface correct) of connection, change code:

connection.response response = jsoup.connect(...) ... 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -