python - Python Selenium 在后台不工作
问题描述
当我使用默认(打开浏览器并执行)运行我的代码时,代码工作但当它尝试运行具有后台结果的代码时什么都没有
from datetime import datetime
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import time
import datetime
import selenium as se
options = se.webdriver.ChromeOptions()
# options.add_argument('--no-sandbox')
# options.add_argument('headless')
driver = se.webdriver.Chrome('c://chromedriver.exe',chrome_options=options)
options.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"')
driver.get('website.com')
time.sleep(2)
当我取消注释时
# options.add_argument('--no-sandbox')
# options.add_argument('headless')
这一行在后台不工作的情况下运行代码,
数据是实时数据,类似于币安数据每 1 分钟更改一次。
解决方案
推荐阅读
- python - 无法使用 networkx 为图形设置权重
- python - 如何提取某些单词的首字母
- shopify - 编辑shopify的管理面板
- typescript - 如果组件用作子组件,则向组件添加额外的接口属性
- laravel - 在查询加载时隐藏模型的属性
- python - Python Wordcloud 只显示变量名
- javascript - 如何将包含逗号的 html 表数据导出到 .csv 文件?
- python - Celery + Azure 服务总线(代理)= 声明为空或令牌无效
- c# - 如何在不将服务注入 .netcore 的情况下从服务中获取注册实例
- c# - 如何将 Dapper QueryFirst 映射到类?