问题:Chrome无痕模式下,无法访问iframe嵌套的页面,页面类似白屏
定位原因:CSP安全策略问题,但是服务端无法支持修改
解决:option中添加一句请求头文章来源:https://www.toymoban.com/news/detail-408211.html
chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36")
所有option:文章来源地址https://www.toymoban.com/news/detail-408211.html
chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--disable-dev-shm-usage') chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36") chrome_options.add_argument('--window-size=1920,1080')
到了这里,关于Refused to frame ‘XXX‘ because an ancestor violates the following Content Security Policy directive:的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!