Python3+Selenium3+webdriver学习笔记10(元素属性、页面源码)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
'''
Selenium3+webdriver学习笔记10(元素属性、页面源码)
'''
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
import re
import time,os
import random # about:addons 火狐浏览器安装组件,访问的地址 # <input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off">
#id
keys="测试部落"
delay=3
# url="https://www.baidu.com/"
url="https://www.cnblogs.com/nicetime"
driver=webdriver.Firefox() driver.get(url) # <a href="http://help.baidu.com/question" target="_blank"
# onmousedown="return c({'fm':'behb','tab':'help','url':this.href,'title':this.innerHTML})">帮助</a> #标题
title=driver.title
print(title) #文本
text=driver.find_element_by_css_selector("div#u>a").text
print(text) #标签名
tagname=driver.find_element_by_css_selector("div#u>a").tag_name
print(tagname) #获取其他属性
classname=driver.find_element_by_css_selector("input#kw").get_attribute("class")
print(classname) #获取文本框的输入内容
driver.find_element_by_id("kw").send_keys(keys)
value=driver.find_element_by_id("kw").get_attribute("value")
print(value) #浏览器名称
print(driver.name)
time.sleep(delay) page=driver.page_source
print(page) result_url=[] url_list=re.findall('href=\"(.*?)\"',page,re.S)
for url in url_list:
if 'http' in url:
result_url.append(url) print(result_url)
driver.quit()
Python3+Selenium3+webdriver学习笔记10(元素属性、页面源码)的更多相关文章
- Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )
!/usr/bin/env python -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )'''from selenium im ...
- Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)'''from sel ...
- Python3+Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)'''from ...
- Python3+Selenium3+webdriver学习笔记11(cookie处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记11(cookie处理)'''from selenium im ...
- Python3+Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)'''from seleni ...
- Python3+Selenium3+webdriver学习笔记8(单选、复选框、弹窗处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记8(单选.复选框.弹窗处理)''' from selenium ...
- Python3+Selenium3+webdriver学习笔记7(选择多链接的结果、iframe、下拉框)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
- Python3+Selenium3+webdriver学习笔记6(多窗口切换处理)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
- Python3+Selenium3+webdriver学习笔记5(模拟常用键盘和鼠标事件)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
随机推荐
- WCF IIS部署
创建WCFHost应用程序 Iservice.cs using System; using System.Collections.Generic; using System.Linq; using S ...
- c++控制台 设置字体颜色
一种方法是直接在程序上方栏杆点右键,然后属性处设置 优点是设置后一劳永逸,不需要像后面方法那样要自己把设置写入程序代码内 缺点是,一旦设置了就不能再改变了,程序从头到尾都是那种设置. 第二种方法是使用 ...
- 懒人模式开启Android模块自动化Api之旅
推荐阅读: 滴滴Booster移动App质量优化框架-学习之旅 一 Android 模块Api化演练 不一样视角的Glide剖析(一) 在将业务进行模块化时,避免不了模块页面路由和模块通信, 大多数我 ...
- API---CreateIoCompletionPort
HANDLE WINAPI CreateIoCompletionPort( __in HANDLE FileHandle, __in HANDLE Existi ...
- CSU - 1580 NCPC2014 Outing(树形依赖+分组背包)
Outing Input Output Sample Input 4 4 1 2 3 4 Sample Output 4 分组背包: for 所有的组k for v=V..0 for 所有的i属于组k ...
- 牛客多校2 D-money(dp记录/贪心)
D-money 链接:https://www.nowcoder.com/acm/contest/140/D来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K, ...
- 关于从request对象中获取路径的问题
从request对象中获取路径的问题:例如: 项目名为:tmall_web 请求的servlet名为:loginServlet 示例代码如下: @Override protected void ...
- Navicat导出数据库结构为PDF
1.选中需要导出的数据表,右键选择 打印表 2.点击左上角 打印,选择标红的打印机,点击确定,然后键入文件名,确定之后会生成后缀为xps的文件 3.然后打开这个网址(https://xpstopdf. ...
- 最棒的Unity Github 项目收集(2016)
http://1darray.com/blog/2016/03/08/best-unity-github-repositories/ List of best public GitHub reposi ...
- OpenGL学习笔记——求值器和NURBS
http://codercdy.com/openglxue-xi-bi-ji-qiu-zhi-qi-he-nurbs/ 在最底层,图形硬件所绘制的是点.直线和多边形(通常是三角形和四边形).平滑的曲线 ...