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 ...
随机推荐
- Struts result param详细设置
<</span>result type="json"> <</span>param name="root">da ...
- day1 java基础回顾-内省
为什么要学内省? 开发框架时,经常需要使用java对象的属性来封装程序的数据,每次都使用反射技术完成此类操作过于麻烦,所以sun公司开发了一套API,专门用于操作java对象的属性. 内省是用于操作j ...
- Fenwick Tree / Binary Indexed Tree
Motivation: Given a 1D array of n elements. [2, 5, -1, 3, 6] range sum query: what's the sum from 2n ...
- h5模型文件转换成pb模型文件
本文主要记录Keras训练得到的.h5模型文件转换成TensorFlow的.pb文件 #*-coding:utf-8-* """ 将keras的.h5的模型文件,转换 ...
- 盛大游戏技术总监徐峥:Unity引擎使用的三种方式
在5月13日Unite 2017 案例分享专场上,盛大游戏技术总监徐峥分享了使用Unity引擎的三种方式,以下为详细内容: 大家好,我先简单介绍一下我自己,我是盛大游戏的技术总监徐峥.我今天想分享的主 ...
- Animation Blueprint, Set Custom Variables Via C++
https://wiki.unrealengine.com/Animation_Blueprint,_Set_Custom_Variables_Via_C%2B%2B Animation Bluepr ...
- ColorMask与Blend
Shader "N/T" { Properties { _Color ("Texture to blend", Color) = (1,1,1,1) } Sub ...
- codeforces590E Birthday【AC自动机+Floyd+匈牙利算法】
因为没有重复串,所以把有包含关系的串连边之后是个DAG,也就是二分图,就变成求二分图的最大独立集=n-最小点覆盖=n-最大匹配 关于包含关系,建出AC自动机,然后把串放上去找子串,但是如果每次都一路找 ...
- JQuery Easyui/TopJUI 创建多级联动下拉框(纯HTML实现!!!)
JQuery Easyui/TopJUI 创建多级联动下拉框(纯HTML实现!!!) 效果展示: 代码如下: <form data-toggle="topjui-form"& ...
- sql 查询重复数据
select user_name,count(*) as count from comm_user group by user_name having count>1;