python - 将 Firefox(由 Selenium 提供支持)历史记录保存到现有用户配置文件
问题描述
我正在研究一个相当简单的 python 脚本,除了浏览网站之外几乎什么都不做(我正在简化一点)
唯一的问题是 - 我必须将浏览历史记录保存到现有的用户配置文件中。我已经阅读了很多关于如何使用\保存到现有 FF 用户配置文件的威胁 -没有成功。
非常感谢关于如何强制硒驱动的 FF 将浏览历史保存到现有 FF 配置文件的 Ant 建议和见解!
我的简化脚本(Selenium| Python3 | 在 Ubuntu 上运行)-->
from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.firefox.options import Options
import time
import sys
import os
import shutil
os.environ['DISPLAY'] = ':10'
os.environ['XAUTHORITY']='/run/user/1000/gdm/Xauthority'
options = Options()
options.set_headless(headless=True)
fp = webdriver.FirefoxProfile('/home/u0002/.mozilla/firefox/htv4hfhr.default')
driver = webdriver.Firefox(options=options,firefox_profile=fp)
driver.get("http://example.com")
解决方案
推荐阅读
- javascript - 如何跨不同模块或js文件更改变量?
- python - 使用 Python 和 Selenium 按标签获取多个元素
- javascript - TS2345:“事件”类型的参数不可分配给“HtmlInputEvent”类型的参数
- sql - SQL 连接查询无法删除同一部电影中演员的重复项?
- javascript - React Native - 执行 UI 块时抛出异常 - 无法识别的选择器?
- python-3.x - 在 Django 中从视图到 url 获取字符串变量
- reactjs - React - 状态是在一个父函数中定义的,但不是在从子函数调用的另一个父函数中
- python - 带有 3D 输入的 Keras 中的 preprocess_input() 方法
- mysql - 计算Mysql中的出现次数
- mysql - Express 永远加载 mySQL 查询?