Refused to frame ‘XXX‘ because an ancestor violates the following Content Security Policy directive:
————————————————版权声明:本文为CSDN博主「Anthony_tester」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本...
·
问题:Chrome无痕模式下,无法访问iframe嵌套的页面,页面类似白屏
定位原因:CSP安全策略问题,但是服务端无法支持修改
解决:option中添加一句请求头
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:
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')
更多推荐
已为社区贡献1条内容
所有评论(0)