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