首页 > 解决方案 > 有没有办法使用 Selenium 禁用 chrome “同源”策略?

问题描述

我正在尝试编写一个脚本,在该脚本中我在 iframe 中抓取元素,但我得到了

Uncaught DOMException: Blocked a frame with origin "https://kith.com" from accessing a cross-origin frame.

我试过这个脚本:

from selenium import webdriver
import os

chop = webdriver.ChromeOptions()

chop.add_argument("--disable-web-security")

# create new Chrome driver object with Chrome extension

driver = webdriver.Chrome(executable_path='chromedriver.exe', options=chop)

并使用我的 chrome 扩展,我尝试在 iframe 中抓取一个元素,但它说它仍然给了我这个错误

标签: pythonseleniumgoogle-chromeiframesame-origin-policy

解决方案


推荐阅读