Java-HttpClient-Douban movie rankings,
Public class TestHttpClient {public static void main (String [] args) throws ClientProtocolException, IOException {// create httpClient instance CloseableHttpClient httpClient = HttpClients. createDefault (); // create httpGetHttpGet httpGet = new HttpGet ("https://movie.douban.com/cinema/nowplaying/nanjing/"); System. out. println (httpGet. getURI (); // execute the get request and receive the response information CloseableHttpResponse response = httpClient.exe cute (httpGet); // obtain the response Entity HttpEntity entity = response. getEntity (); // print the response status System. out. println (response. getStatusLine (); System. out. println ("---------------------------------"); if (entity! = Null) {String web = EntityUtils. toString (entity, "UTF-8"); // System. out. println ("response content length" + entity. getContentLength (); // System. out. println ("response content" + web); Document doc = Jsoup. parse (web); // obtain the ranking title Elements title = doc. getElementsByClass ("movie_ranking_time"); for (Element element: title) {System. out. println (element. text ();} // obtain the ranking type Elements name = doc. select ("ul. tab_nav> li "); // obtain the ranking table Elements content = doc. select ("ul. view_1 "); for (int I = 0; I <name. size (); I ++) {System. out. println (name. get (I ). text (); Elements movie = content. get (I ). select ("li"); for (int j = 0; j <movie. size (); j ++) {System. out. println (movie. get (j ). text () ;}} System. out. println ("---------------------------------"); response. close (); httpClient. close ();}}