Python uses the Requests module to Get the page content.
What are we going to use for the Requests module? This module can send network requests (Get, Post, Delete… …). We use this module to make an Http Get request so that we can Get the page. To use this module we need to install it with PIP:
python -m pip install requests
Copy the code
After the installation is complete, we can load the code (not to say more) :
# -*- coding: UTF-8 -*-
import requests # import requests package
url = "https://www.csdn.net"; # request url
html_str = requests.get(url) Send a Get request
print(html_str.text) Get the result and print the value of the Text property to get the content of the web page
Copy the code
The running results are as follows: