All pastes #365968 Raw Edit

Something

public java v1 · immutable
#365968 ·published 2007-02-21 12:02 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...");        HttpUnitOptions.setScriptingEnabled( false );        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()+".html")); //We write the source into a file*                //Alle anderen Seiten.        boolean passed = false;        System.out.println("Get the following pages....");        while(isRunning == true){            HttpUnitOptions.setScriptingEnabled( true );                        WebLink link = resp.getLinkWithImageText("Page 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 {                resp = link.click();  // We get the result.                resp = wc.getCurrentPage();  //Referencing (!)                source = readout(resp.getInputStream()); //We fetch the source.                if(!source.isEmpty()){ //Prevents from writing 0KB-Files.                    System.out.println("Running...");                    System.out.println("Source of page-follower extracted: "+source);                    //Source der ersten Seite in den Array:                    writeCode(source, new File(rootfolder+System.currentTimeMillis()+".html")); //We write the source into a file.                } //END of IF-Source-Emptry                            } //END of IF-LINK                    } //END of WHILE.            } //END of FUNCTION