How to view webpage code with python:
1、 Use "import" to import the requests package
import requests
2、 Use the get() function of the requests package to get the source code of the web page through the web link, and then use the print() statement to output it.
The results are as follows:
Example extension:
Python get web page html code
Get the html code of the webpage:
import requests
res = requests.get('https://www.zalou.cn/Change to your webpage.html')
res.encoding ='utf-8'print(res.text)
operation result:
So far, this article on how to view webpage code in python is introduced. For more related python view webpage code methods, please search for the previous articles of ZaLou.Cn or continue to browse the related articles below. Hope you will support ZaLou.Cn more in the future. !
Recommended Posts