如何使用Python查看网页源代码内容?
- 内容介绍
- 文章标签
- 相关推荐
本文共计206个文字,预计阅读时间需要1分钟。
使用Python查看网页源码的方法:
1.导入requests包:import requests
2.使用requests包的get()函数通过网页链接获取源码,然后使用print()语句输出源码内容。
执行结果如下:
pythonimport requestsurl=你的网页链接source_code=requests.get(url).textprint(source_code)用python查看网页代码的方法:
1、使用“import”导入requests包
import requests
2、使用requests包的get()函数通过网页链接获取网页的源码,然后使用print()语句输出就可以了
执行结果如下:
实例扩展:
Python获取网页html代码
获取网页html代码:
import requests res = requests.get('www.jb51.net/更换成你的网页.html') res.encoding = 'utf-8' print(res.text)
运行结果:
到此这篇关于python如何查看网页代码的文章就介绍到这了,更多相关python查看网页代码方法内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!
本文共计206个文字,预计阅读时间需要1分钟。
使用Python查看网页源码的方法:
1.导入requests包:import requests
2.使用requests包的get()函数通过网页链接获取源码,然后使用print()语句输出源码内容。
执行结果如下:
pythonimport requestsurl=你的网页链接source_code=requests.get(url).textprint(source_code)用python查看网页代码的方法:
1、使用“import”导入requests包
import requests
2、使用requests包的get()函数通过网页链接获取网页的源码,然后使用print()语句输出就可以了
执行结果如下:
实例扩展:
Python获取网页html代码
获取网页html代码:
import requests res = requests.get('www.jb51.net/更换成你的网页.html') res.encoding = 'utf-8' print(res.text)
运行结果:
到此这篇关于python如何查看网页代码的文章就介绍到这了,更多相关python查看网页代码方法内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!

