Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31927

Re: how to capture full webpage in java

From Eternal Hope <laughingspam99@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: how to capture full webpage in java
Date 2015-07-02 20:46 +0100
Organization A noiseless patient Spider
Message-ID <mn44cq$o4i$1@dont-email.me> (permalink)
References <b93849bb-23f7-4867-bd3e-81ba9157b5c6@googlegroups.com>

Show all headers | View raw


On 30/06/2015 10:13, Navneet Mathpal wrote:
> Hi ,
> Have you tried to capture the full webpage using java ?
> I want to capture full webpage using java (ex: http://stackoverflow.com) . I am able to capture the first screen but can not scoll down till the web-page ends ?
>
> I tried to do it with Selenium , but could not do it(some jar problem occuring all the time )
>
>
> could you please help. ?

package usenet.foo;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class PageReader {
	
	public static void main(String[] args){
		URL url = null;
	    BufferedReader reader = null;
	    StringBuilder stringBuilder;
	
	    try{
	
	      url = new URL("http://stackoverflow.com");
	      HttpURLConnection connection = (HttpURLConnection) 
url.openConnection();
	      connection.setRequestMethod("GET");
	      connection.setReadTimeout(15*1000);
	      connection.connect();
	      reader = new BufferedReader(new 
InputStreamReader(connection.getInputStream()));
	      stringBuilder = new StringBuilder();
	
	      String line = null;
	      while ((line = reader.readLine()) != null) {
	        stringBuilder.append(line + "\n");
	      }
	      //parse or whatever
	      System.out.println(stringBuilder.toString());
	    }
	    catch (Exception e){
	      e.printStackTrace();
	  }
	}
}

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

how to capture full webpage in java Navneet Mathpal <navneetmathpal93@gmail.com> - 2015-06-30 02:13 -0700
  Re: how to capture full webpage in java e.d.programmer@gmail.com - 2015-06-30 05:34 -0700
  Re: how to capture full webpage in java Eternal Hope <laughingspam99@gmail.com> - 2015-07-02 20:46 +0100
    Re: how to capture full webpage in java Eternal Hope <laughingspam99@gmail.com> - 2015-07-02 20:50 +0100
      Re: how to capture full webpage in java e.d.programmer@gmail.com - 2015-07-02 12:58 -0700

csiph-web