Get Web content based on Apache-httpclient's small reptile

Source: Internet
Author: User

Today (17-03-31) a busy afternoon studying webmagic, found himself too young for such a difficult framework (class library)

Still difficult to accept, or start from the basics, because the relatively basic things tutorial more, so I looked for Apache under the

HttpClient, according to the predecessors sent the tutorial himself also simple write a bit, feel good.

The following implementation is the acquisition of a single page:

Importorg.apache.http.HttpEntity;ImportOrg.apache.http.HttpResponse;Importorg.apache.http.client.HttpClient;ImportOrg.apache.http.client.methods.HttpGet;Importorg.apache.http.impl.client.HttpClients;Importorg.apache.http.util.EntityUtils;Importjava.io.IOException; Public classMain { Public Static voidMain (string[] args)throwsioexception{Try {            //Create a client instanceHttpClient client=Httpclients.createdefault (); //Creating an HttpGet instanceHttpGet httpget=NewHttpGet ("http://www.btba.com.cn"); //perform a GET requestHttpResponse response=Client.execute (HttpGet); //returns the Get entityHttpentity entity=response.getentity (); //get Web page content, specify encodingString web= entityutils.tostring (Entity, "UTF-8"); //Output Web pageSystem.out.println (web); } Catch(IOException e) {e.printstacktrace (); }    }}

Some shows:

The following is a httpclient download: http://hc.apache.org/downloads.cgi

WebMagic based on HttpClient, Jsoup So, now will these two learned, learned to try to chew webmagic it

The next jsoup for this download page simple parsing processing ...

I am still small white one, above have what insufficient or wrong place please point out, thank you very much.

Get Web content based on Apache-httpclient's small reptile

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.