Python WebDriver how to print whole page source (html)(Python WebDriver如何打印整个页面源(html))
本文介绍了Python WebDriver如何打印整个页面源(html)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有 Selenium WebDriver 的 Python 2.7.我的问题是如何使用 print
方法打印整个页面源代码.有 webdriver 方法 page_source
但它返回 WebDriver 我不知道如何将它转换为 String 或只是在终端打印它
I'm using Python 2.7 with Selenium WebDriver.
My question is how to print whole page source with print
method.
There is webdriver method page_source
but it returns WebDriver and I don't know how to convert it to String or just print it in terminal
推荐答案
.page_source
在 webdriver
实例上是你需要的:
>>> from selenium import webdriver
>>> driver = webdriver.Firefox()
>>> driver.get('http://google.com')
>>> print(driver.page_source)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" itemtype="http://schema.org/WebPage" itemscope=""><head><meta name="descri
...
:before,.vscl.vslru div.vspib{top:-4px}</style></body></html>
这篇关于Python WebDriver如何打印整个页面源(html)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:Python WebDriver如何打印整个页面源(html)


基础教程推荐
猜你喜欢
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 筛选NumPy数组 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01