This groovy example will show how to get fetch the contents of a web page. A similar example shows how get content from a url or uri in java.
@Test public void get_url_content() { def urlContents = "https://github.com/leveluplunch/levelup-java-examples/blob/master/README.md".toURL().getText() urlContents.eachLine { println it //read each line of the web page99 } }
<!DOCTYPE html> <html lang="en" class=""> <head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# object: http://ogp.me/ns/object# article: http://ogp.me/ns/article# profile: http://ogp.me/ns/profile#"> <meta charset='utf-8'> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="Content-Language" content="en"> <title>levelup-java-examples/README.md at master · leveluplunch/levelup-java-examples · GitHub</title> <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub"> //... <div id="ajax-error-message" class="flash flash-error"> <span class="octicon octicon-alert"></span> <a href="#" class="octicon octicon-x flash-close js-ajax-error-dismiss" aria-label="Dismiss error"></a> Something went wrong with that request. Please try again. </div> <script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/frameworks-7e989cd35c6790acb51890a1e7abd63edb596bed83c3b99ac299180550d5b096.js" type="text/javascript"></script> <script async="async" crossorigin="anonymous" src="https://assets-cdn.github.com/assets/github-bc67a5e08f8b3d0bd9c93d20051c3afec55dc9c4f596f4a61506e4d7d7d94478.js" type="text/javascript"></script> </body> </html>