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 matplotlib以日期为x轴作图代码实例

Python matplotlib以日期为x轴作图代码实例

这篇文章主要介绍了Python matplotlib以日期为x轴作图代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 效果图如下...

python中列表的切片与修改知识点总结

python中列表的切片与修改知识点总结

python中可以使用下标索引来访问列表中的值,对列表进行切片即截取,也可以对列表的数据项进行修改或更新。 使用下标索引来访问列表中的值,例如list1[1]。 使用索引截取列表中的值...

Python使用ctypes调用C/C++的方法

python使用ctypes调用C/C++ 1. ctpes介绍 ctypes is a foreign function library for Python. It provides...

python输出指定月份日历的方法

本文实例讲述了python输出指定月份日历的方法。分享给大家供大家参考。具体实现方法如下: #!/usr/bin/python import calendar cal = calen...

python连接mysql实例分享

示例一 #coding=UTF-8 import sys import MySQLdb import time reload(sys) sys.setdefaultencodin...