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


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

Re: how to capture full webpage in java

Newsgroups comp.lang.java.programmer
Date 2015-07-02 12:58 -0700
References <b93849bb-23f7-4867-bd3e-81ba9157b5c6@googlegroups.com> <mn44cq$o4i$1@dont-email.me> <mn44k2$o4i$2@dont-email.me>
Message-ID <3a6ee5dc-b09f-4fc3-b9b0-95e73f303d5b@googlegroups.com> (permalink)
Subject Re: how to capture full webpage in java
From e.d.programmer@gmail.com

Show all headers | View raw


On Thursday, July 2, 2015 at 3:50:54 PM UTC-4, Eternal Hope wrote:
> On 02/07/2015 20:46, Eternal Hope wrote:
> > 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();
> >        }
> >      }
> > }
> 
> That took 2 minutes to find, 2 minutes to modify and 30 seconds to test :-)

Web is a funny thing.  My guess was the solution would be similar to my solution, where I wrote a drag and drop handler to drag an image from a web page and drop it into a JComponent.  Initially I only got part of a file.  I had to use a different method to retrieve the entire file.

Back to comp.lang.java.programmer | Previous | Next — Previous 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