java - parsing amazon page using jsoup returns 204 status -
sample page: http://www.amazon.com/gp/offer-listing/1589942140
public void connect( string url ) { this.conn = jsoup.connect( url ); } /** * executes request , parses result. * @return */ public boolean parse() { try { this.page = this.conn.get(); return true; } catch (ioexception ex) { // log here system.out.format("error: %s%n", ex); return false; } }
parsing page creates ioexception below:
org.jsoup.httpstatusexception: http error fetching url. status=204, url=http://www.amazon.com/gp/offer-listing/1589942140
i tried native java url class below , it's not creating ioexception:
try { url myurl = new url("http://rads.stackoverflow.com/amzn/click/1589942140"); urlconnection myurlconnection = myurl.openconnection(); myurlconnection.connect(); system.out.format("%s", myurlconnection.getcontenttype()); } catch (malformedurlexception e) { // new url() failed system.out.format("error: %s%n", e); } catch (ioexception e) { // openconnection() failed system.out.format("error: %s%n", e); }
any ideas why ?
the following works me:
system.out.println(jsoup.connect("http://rads.stackoverflow.com/amzn/click/1589942140").useragent("mozilla").get().text());;
the url tried above specified above. (sample page: http://www.amazon.com/gp/offer-listing/1589942140)
Comments
Post a Comment