web scraping - Fetch source code of web page using java? -
web scraping - Fetch source code of web page using java? -
i have url this , next method
public static void savecontent( string weburl )throws exception { url website = new url(weburl); urlconnection connection = website.openconnection(); bufferedreader in = new bufferedreader( new inputstreamreader( connection.getinputstream())); stringbuilder response = new stringbuilder(); string inputline; while ((inputline = in.readline()) != null) response.append(inputline); in.close(); system.out.println(response.tostring()); }
however, when want print web content, fetches source code of main page(www.google.com).
how can solve problem ? help.
i copied yours code netbeans , seems work correctly. think problem lead on content in method argument "weburl". seek run app on debug mode , you've got there.
java web-scraping
Comments
Post a Comment