@@ -0,0 +1,2324 @@
+package data_manipulation;%0A%0Aimport java.io.IOException;%0Aimport java.net.MalformedURLException;%0A%0Aimport com.gargoylesoftware.htmlunit.BrowserVersion;%0Aimport com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;%0Aimport com.gargoylesoftware.htmlunit.WebClient;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlButton;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlForm;%0Aimport com.gargoylesoftware.htmlunit.html.HtmlPage;%0A%0Apublic class D0623_test_googleRes %7B%0A%09%0A%09public static void main(String%5B%5D args) throws FailingHttpStatusCodeException, MalformedURLException, IOException%7B%0A%09%09%0A%09%09%0A%09%09WebClient webClient = new WebClient(BrowserVersion.CHROME);%0A%09%09%0A%09%09webClient.getOptions().setJavaScriptEnabled(false);%0A%09%09webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);%0A%09%09webClient.getOptions().setThrowExceptionOnScriptError(false);%0A%0A%09%09String%5B%5D searchString = %7B%22TTN%22, %22TNN%22, %22SAMD11%22, %22GPR160%22%7D; %0A%09%09%0A%09%09//HtmlPage page = webClient.getPage(%22http://exac.broadinstitute.org/%22);%0A%09%09HtmlPage page = webClient.getPage(%22https://google.com/%22);%0A%09%09%0A%09%09//getting Form from the home page. tsf is the form name of google.com%0A%09%09HtmlForm form = page.getHtmlElementById(%22tsf%22);%0A%09%09%0A%09%09//iterate programming languages to find no.of results%0A%09%09for(int i=0; i%3CsearchString.length; i++)%7B%0A%09%09%09%0A%09%09%09//setting programming language name as value in search box in the search home page%0A%09%09%09form.getInputByName(%22q%22).setValueAttribute(searchString%5Bi%5D);%0A%09%09%09%0A%09%09%09//creating a virtual submit button%0A%09%09%09HtmlButton submitButton = (HtmlButton)page.createElement(%22button%22);%0A%09%09%09submitButton.setAttribute(%22type%22, %22submit%22);%0A%09%09%09form.appendChild(submitButton);%0A%09%09%09%0A%09%09%09%0A%09%09%09//submitting the form and getting the result%0A%09%09%09HtmlPage newPage = submitButton.click();%0A%09%09%09%0A%09%09%09//getting the result as text%0A%09%09%09String pageText = newPage.asText();%0A%09%09%09String results%5B%5D = pageText.split(%22%5Cn%22);%0A%09%09%09%0A%09%09%09%0A%09%09%09//getting the lines which contains the no.of results value.%0A%09%09%09%0A%09%09%09for(int j=0; j%3Cresults.length; j++)%7B%0A%09%09%09%09%0A%09%09%09%09if(results%5Bj%5D.contains(%22About%22) && results%5Bj%5D.contains(%22results%22))%0A%09%09%09%09%09System.out.println(searchString%5Bi%5D + %22------%22 + results%5Bj%5D);%0A%09%09%09%09%0A%09%09%09%7D//end inner loop for j%3Cresults.length;%0A%09%09%09%0A%09%09%7D//end outter loop for i%3CsearchString.length;%0A%09%09%0A%09%09//String pageContent = page.asText(); %0A%09%09%0A%09%09//System.out.println(pageContent);%0A%09%09%0A%09%09webClient.close();%0A%09%7D//end main()%0A%09%0A%0A%7D//ee%0A

add java HtmlUnite example code, to pull data from website