All pastes #364905 Raw Edit

RockSolid

public java v1 · immutable
#364905 ·published 2007-02-20 14:07 UTC
rendered paste body
private void generatePages(String City, String Branche, String rootfolder) throws SAXException, MalformedURLException, IOException{                  System.out.println("Started...");                  boolean isRunning = true;                                             //THE FIRST PAGE                String source;                WebConversation wc = new WebConversation();                                System.out.println("Going to main-search-page...");                               WebResponse resp = wc.getResponse("http://wappc.pagesjaunes.fr/pj.cgi"); //We go to the form.                                System.out.println("Doing form-request...");                    WebForm form = resp.getForms()[0];   // select the first form in the page                    System.out.println("Form-Name: "+form.getName());                       form.setParameter( "FRM_ACTIVITE", Branche );      // Insert values...                       form.setParameter( "FRM_LOCALITE", City );         // Insert values...                System.out.println("Submitting...");                       resp = form.submit();                                     //We submit the filled form.                System.out.println("Done Submit...");                                                           source = readout(resp.getInputStream());    //We fetch the source-code of the page.                System.out.println("Got the first page:"+source);                                                //Source der ersten Seite in eine File:                writeCode(source, new File(rootfolder+System.currentTimeMillis())); //We write the source into a file*                                          /////                                             //Alle anderen Seiten.            boolean passed = false;            System.out.println("Get the following pages....");            while(isRunning == true){                                                   System.out.println("Running...");                                        WebLink link = resp.getLinkWithImageText("suivante");   //We go to the picture with the alt-tag "suivante"                 if(link == null){ System.out.println("No new \"Next\"-Link found..."); isRunning = false; break;  } else {                    link.click();                        // We follow the link.                                           resp = wc.getCurrentPage();          // Wir get the result.                                     source = readout(resp.getInputStream()); //Wir fetch the source.                System.out.println("Source of page-follower extracted: "+source);                //Source der ersten Seite in den Array:                writeCode(source, new File(rootfolder+System.currentTimeMillis())); //We write the source into a file.                                                   }                                       } //END of WHILE.                                                                                           } //END of FUNCTION