Error in user YAML: (<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1
---
- oeasy Python 0562
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
本教程同步发布在:
个人网站: `https://oeasy.org`
蓝桥云课: `https://www.lanqiao.cn/courses/3584`
GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
Gitee: `https://gitee.com/overmind1980/oeasypython`
---- 上次使用selenium模拟了浏览器的行为
- 模拟了填写表单的过程
- 可以填写表单加回车
- 也可以填写表单点击按钮
- 很多日常的填报工作可以用selenium的方式来填报提交
- 大幅提高效率
- 所谓无头模式
- 就是不启动 图形用户界面
- 直接在终端里面运行的模式
- 具体怎么用呢?
- 设置driver中的arguement
- 执行命令
- 确实firefox命令
- 可以有这么一个参数
- 具体 如何使用呢?
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service
from selenium import webdriver
from lxml import etree
import time
service = Service(executable_path="geckodriver")
options = webdriver.FirefoxOptions()
options.add_argument("-headless")
driver = webdriver.Firefox(options=options,service=service)
driver.get("http://baidu.com")
text_box = driver.find_element(by=By.NAME, value="wd")
text_box.send_keys("Selenium")
text_box.send_keys(Keys.ENTER)
time.sleep(5)#延迟时间等待响应
message = driver.title
print(message)
driver.quit()
- 产生结果
-
这次我们了解了
- 无头模式
- headless
- 可以不启动浏览器ui
- 直接就执行相关代码
-
我们下次玩点什么呢?🤔
-
下次再说👋
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。



