July 2017
Beginner to intermediate
715 pages
17h 3m
English
There is a lot of data on the Internet nowadays, and being able to access this data and transform it into something machine-readable is a very important skill for a Data Scientist.
There are multiple ways of accessing data from the Internet. Luckily for us, the standard Java API provides a special class for doing that, URL. With URL, it is possible to open an InputStream, which will contain the response body. For web pages it typically is its HTML content. With IOUtils from Commons IO, doing this is simple:
try (InputStream is = new URL(url).openStream()) { return IOUtils.toString(is, StandardCharsets.UTF_8); }
This piece of code is quite useful, so putting it into some helper method, for example, UrlUtils.request, will be ...