Mac环境下无需安装Microsoft Edge能否通过Selenium运行?
Hey there! Great question—you absolutely can run Selenium scripts targeting Edge without installing the full Edge DMG package, which is perfect for saving storage space. Here are the practical ways to make this work for your Bing Rewards + Airflow project:
1. Use a Portable/Unpacked Edge Build
Instead of installing the official DMG, grab a portable version of Edge (no installation required—just unzip and run). This lets you point Selenium directly to the browser binary without modifying your system's installed apps.
Example Python Script:
from selenium import webdriver from selenium.webdriver.edge.options import Options # Configure Edge options edge_options = Options() # Point to your portable Edge binary path (adjust this to your actual file location) edge_options.binary_location = "/Users/you/path/to/portable-edge/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" # Enable headless mode (critical for Airflow background execution—no browser window pops up) edge_options.add_argument("--headless=new") # Add resource-saving flags edge_options.add_argument("--disable-gpu") edge_options.add_argument("--no-sandbox") edge_options.add_argument("--disable-dev-shm-usage") # Initialize the driver driver = webdriver.Edge(options=edge_options) # Your Bing Rewards automation logic here driver.get("https://www.bing.com") # ... rest of your script ... # Clean up driver.quit()
2. Key Compatibility Note
Make sure the version of Edge WebDriver you download matches exactly with your portable Edge build. To check Edge's version:
- Run this command in your terminal:
"/Users/you/path/to/portable-edge/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" --version - Grab the corresponding WebDriver, extract the
msedgedriverbinary, and place it in a path accessible by your Airflow worker (no installation needed).
3. Airflow-Specific Tips
- Store the portable Edge folder and WebDriver binary in a location your Airflow workers can access (e.g., a shared directory or a path defined in your Airflow
PATHenvironment variable). - Avoid relative paths in your script—use absolute paths to prevent file not found errors when Airflow runs the task.
This approach not only saves storage but also runs efficiently in Airflow's headless environment, making it ideal for automated Bing Rewards tasks.
内容的提问来源于stack exchange,提问作者Flash Gordon

