python+selenium打印当前页面的titl和url方法

yipeiwu_com6年前Python基础

dr.title //获取页面title

dr.current_url // 获取页面url

代码如下:

from selenium import webdriver

dr = webdriver.Firefox()
url = 'http://www.baidu.com'
dr.get(url)
# 获取页面title
title = dr.title
# 获取页面url
url = dr.current_url
print title
print url
dr.quit()

以上这篇python+selenium打印当前页面的titl和url方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python环境下搭建属于自己的pip源的教程

一、安装pip2pi工具: pip install pip2pi 或: git clone https://github.com/wolever/pip2pi cd pip2...

python NumPy ndarray二维数组 按照行列求平均实例

我就废话不多说了,直接上代码吧! c = np.array([[1, 2, 3, 4], [4, 5, 6, 7], [7, 8, 9, 10]]) print(c.mean(axi...

Python多线程编程(一):threading模块综述

Python这门解释性语言也有专门的线程模型,Python虚拟机使用GIL(Global Interpreter Lock,全局解释器锁)来互斥线程对共享资源的访问,但暂时无法利用多处理...

Python列表切片用法示例

本文实例讲述了Python列表切片用法。分享给大家供大家参考,具体如下: Python中符合序列的有序序列都支持切片(slice),例如列表,字符串,元组。   &n...

tornado框架blog模块分析与使用

复制代码 代码如下:#!/usr/bin/env python## Copyright 2009 Facebook## Licensed under the Apache License...