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实现的可以拷贝或剪切一个文件列表中的所有文件

复制代码 代码如下:# coding:utf-8 import os import sys def cut_and_paste_file(source, destination): &n...

python新手经常遇到的17个错误分析

1)忘记在 if , elif , else , for , while , class ,def 声明末尾添加 :(导致 “SyntaxError :invalid syntax”)...

Python中字符串与编码示例代码

在最新的Python 3版本中,字符串是以Unicode编码的,即Python的字符串支持多语言 编码和解码    字符串在内存中以Unicode表示,在操作字符串时,经常需要...

Python中的getopt函数使用详解

函数原型: getopt.getopt(args, shortopts, longopts=[]) 参数解释:     args:args...

python类定义的讲解

一、类定义:复制代码 代码如下:class <类名>: <语句>类实例化后,可以使用其属性,实际上,创建一个类之后,可以通过类名访问其属性。如果直接使用...