Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package steamdb.parser; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URI; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; /** * * @author */ public class HttpGetRequest { private HttpClient client; private final String USER_AGENT = "Mozilla/5.0"; HttpGetRequest() { client = HttpClientBuilder.create().build(); } public String getPage(String url) throws Exception { URI uri = new URI(url); HttpGet request = new HttpGet(url); HttpResponse response = client.execute(request); // System.out.println("Response Code : " + // response.getStatusLine().getStatusCode()); BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer result = new StringBuffer(); String line = ""; while ((line = rd.readLine()) != null) { result.append(line); } return result.toString(); } }