python - 如何在 python 中请求输入时在后台运行 selenium 脚本
问题描述
我正在使用 python 自动化一些任务,我使用 selenium 来完成它。但我希望它在后台运行时询问用户输入(我不是指无头模式)。我希望终端看起来像 Metasploit 控制台中的那种,我们可以在后台运行漏洞利用或作业时做其他事情。
假设我example.com
在 python3 中抓取网页
from selenuim import webdriver
driver=webdriver.Firefox(executable_path='blaah')
driver.get('https://example.com')
while True:
#do something
# do something else.
# A loop starts here for any other task
for i in range(something):
#do somethings else
当它执行这些循环时,我想要求用户输入。但这不应该影响循环。exit
但是如果用户说没有关闭硒窗口,我确实希望循环中断。例如:
if userInp.lower()=='exit':
print("EXIting now")
# DO SOMETHING that will affect the selenium window.
#Like logging out of an account if its logged in
- 我可以使用线程,但不知道如何。
- 我不是在谈论无头模式
- 笔记; python3和linux
解决方案
推荐阅读
- xml - 如何在 XSLT 的节点中只选择一个元素?
- node.js - 如何为此异步函数添加超时
- html - 在网站上拥有封面大小的响应式视频背景的最佳方式
- android - Gradle 出错:无法获取 ProductFlavor_Decorated 的未知属性“项目”
- c - 在循环队列中插入和删除元素
- java - 使用 Arraylist 值创建一个 HashMap 数组
- javascript - 使用 v-for 在 vc-date-picker > v-text-field 中更改 :value
- c++ - 未解析的外部符号 WSASetSocketSecurity
- lua - 用于检测“唯一幸存者”获胜者的 Roblox 游戏脚本
- python - 在 Python 中检测 OS 暗模式