《2018年7月5日》【连续267天】
标题:Selenium库;
内容:
1.显示器突然出现了一道黄线,尝试了网上各种方法,都没用,换了输入,发现就是显示器的锅:
贴吧老哥说这是排线坏了,没救了,换屏吧
2.YPbPr接口,也称色差分量接口,它将音视频信号分为红、绿、蓝三条信号的传输,极大地减少了信号之间的相互干扰。其中Y代表亮度,Pb代表蓝色信号,Pr代表红色信号。
3.Selenium库学习:
from selenium import webdriver
browser = webdriver.Ie()
browser.get('http://www.baidu.com/')
运行这段代码,会自动打开浏览器,然后访问百度。
不过记得要下一个Ie驱动,
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
在这个网站下;
页面交互:
对于
<input type="text" name="passwd" id="passwd-id" />
获取:element = driver.find_element_by_id("passwd-id")
element = driver.find_element_by_name("passwd")
element = driver.find_elements_by_tag_name("input")
element = driver.find_element_by_xpath("//input[@id='passwd-id']")
输入:
element.send_keys("some text")
页面切换:
driver.switch_to_window("windowName")
弹窗处理:alert = driver.switch_to_alert()
历史记录:
driver.forward()
driver.back()
Cookies处理:
添加:
# Go to the correct domain
driver.get("http://www.example.com")
# Now set the cookie. This one's valid for the entire domain
cookie = {‘name’ : ‘foo’, ‘value’ : ‘bar’}
driver.add_cookie(cookie)
获取:
# Go to the correct domain
driver.get("http://www.example.com")
# And now output all the available cookies for the current URL
driver.get_cookies()