download:Go语言开发分布式任务调度 轻松搞定高性能Crontab
Golang因其强大的协程机制,现已广泛应用于解决分布式环境下的高并发问题。本门课程中将结合Etcd与MongoDB实现一个基于Master-Worker分布式架构的任务调度系统。你不仅将掌握Golang的工程实践能力,而且会收获诸如CAP、Raft的分布式经典理论与架构经验,”工程能力”与”知识体系”齐头并进,实现华丽质变。
适合人群
希望转型Go语言开发的同学
需要提升Go语言的开发经验的同学
技术储备要求
熟悉Go语言基础语法,具备一定开发经验更佳
了解Linux Shell、Github、MySQL的简单用法
import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
启动Chromedriver,并与Chromedriver开启会话
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://www.baidu.com")
第一步:实例化ActionChains
ac = ActionChains(driver)
第二步:定位要操作的元素
ele = driver.find_element_by_xpath('//span[@id="s-usersetting-top"]')
第三步:执行对应的操作
ac.move_to_element(ele) # 悬浮操作
第四步,释放鼠标动作
ac.perform()
点击悬停出来的页面上的元素
wait = WebDriverWait(driver, 10)
loc = (By.XPATH, '//a[@class="setpref"]')
wait.until(EC.visibility_of_element_located(loc))
driver.find_element(*loc).click()
time.sleep(2)
driver.quit()
def move_to():
print("正在挪动")
def click():
print('点击')
actions = []
actions.append(move_to)
actions.append(click)
for action in actions: # perform
action = move_to
action()
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
启动Chromedriver,并与Chromedriver开启会话
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("http://www.baidu.com")
driver.find_element_by_id('kw').send_keys("selenium") # 没有点击百度一下也没有回车不会呈现搜索结果
time.sleep(2)
driver.find_element_by_id('kw').send_keys(Keys.CONTROL,'a') # 全选然后输入新内容python
driver.find_element_by_id('kw').send_keys('python', Keys.ENTER) # 用回车替代点击搜索按钮
time.sleep(2)
driver.find_element_by_id('kw').send_keys('python') # 也能够单独先输内容
driver.find_element_by_id('kw').send_keys(Keys.ENTER) # 再回车
time.sleep(2)
driver.quit()
<html>
<head>
<meta charset="UTF-8">
<title>下拉框演示</title>
</head>
<body>
<select id="province">
<option value="sj">深圳</option>
<option value="gd">广东</option>
<option value="sh">上海</option>
<option value="bj">北京</option>
</select>
<select id="city">
<option value="sj">深圳</option>
<option value="gz">广州</option>
<option value="sh">上海</option>
<option value="bj">北京</option>
</select>
</body>
</html>
演示代码如下:
import time
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.ui import Select
启动Chromedriver,并与Chromedriver开启会话
driver = webdriver.Chrome()
driver.maximize_window()
driver.get(r"D:\learn\test.html")
wait = WebDriverWait(driver, 10)
找到select元素
ele = driver.find_element_by_id('province')
实例化Select类
s = Select(ele)
time.sleep(1)
s.select_by_value('gd') # 经过value属性选值
time.sleep(2)
s.select_by_index(2) # 经过下标index选值
time.sleep(2)
s.select_by_visible_text('北京') # 经过文本内容选值
time.sleep(2)
driver.quit()
import time
import datetime
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
启动Chromedriver,并与Chromedriver开启会话
driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://www.12306.cn/")
wait = WebDriverWait(driver, 30)
loc = (By.XPATH, '//input[@id="train_date"]')
wait.until(EC.visibility_of_element_located(loc))
js = 'document.getElementById("train_date").readOnly=false;'
driver.execute_script(js)
time.sleep(2)
清空日历,重新输入日期
driver.find_element(*loc).clear()
today = datetime.date.today()
tomorrow = today + datetime.timedelta(days=1)
driver.find_element_by_id('train_date').send_keys(str(tomorrow))
time.sleep(2)
driver.quit()
有疑问加站长微信联系(非本文作者)