首页 > 解决方案 > 将 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")

标签: pythonlinuxseleniumfirefoxwebdriver

解决方案


推荐阅读