Java-httpclient-'s watercress film rankings

Source: Internet
Author: User

Tag:pac   client   utils   length    response     ext   etc   ntp   lin   

public class Testhttpclient {public static void main (string[] args) throws Clientprotocolexception, IOException {//Create HTTP Client Instance closeablehttpclient Httpclient=httpclients.createdefault ();//Create Httpgethttpget httpget=new httpGet ("https ://movie.douban.com/cinema/nowplaying/nanjing/"); System.out.println (Httpget.geturi ());//execute GET request and receive response information Closeablehttpresponse response= Httpclient.execute (httpget) ;//Get response entity httpentity entity= response.getentity ();//Print 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);D ocument doc= jsoup.parse (Web);//Get leaderboard title elements title =doc.getelementsbyclass ("Movie_ranking_time"); for (element element: title) {System.out.println (Element.text ());} Gets the leaderboard type elements name =doc.select ("Ul.tab_nav>li");//Get leaderboard 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 ();}}

Java-httpclient-'s watercress movie rankings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.