python requests the library for the first time

Installation requests library

Execution pip3 install requests

Use resquests library to obtain Baidu Home

  1. Open python idle terminals. To python3 example, python3 executed in the terminal and press Enter.

  2. Enter the import requests, represents a reference requests library.

  3. Input requests.get = R & lt ( " http://www.baidu.com "), indicates to get way to obtain Baidu page.

  4. r.status_code return 200, which returns success.

  5. r.encoding = 'utf-8' encoding modified.

  6. r.text print web content.

Guess you like

Origin www.cnblogs.com/MyLifeMyWay/p/11566931.html