Probe into the python3 reptile (II.) requests

Source: Internet
Author: User

Regarding the request webpage, had to mention requests this library, this is the reptile frequently uses a third-party library, installs with the PIP.

There are a lot of requests, and there are only a few basics here, and other advanced features can refer to the official documentation.

ImportRequestsurl='http://www.baidu.com'#Here you use the Get method to request a Web page, and other methods such as post to request a Web pagedata =requests.get (URL)Print(data)#<response [200]>Print(Data.text)#here the. Text is equivalent to the read () in the previous article#at this time also print out the source page#<! DOCTYPE html><!--STATUS ok--># Gets the encoding of the page print(code)#utf-8= Data.status_code# get the status code to check if the request was successful print(page_status)#200 

These are the basic uses of requests, and crawlers begin to grasp these simple usages. The requests will continue to be summarized later.

Probe into the python3 reptile (II.) requests

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.