拒绝访问您无权访问“在服务器上使用ChromeDriver和Chrome通过Selenium Python [英] Access Denied You don't have permission to access "site" on this server using ChromeDriver and Chrome through Selenium Python
问题描述
我一直在使用硒和铬,并且一直在尝试访问网站,但是我一直收到以下错误消息:
I've been using selenium with chrome and I've been trying to access a website but I keep receiving this error message:
Access Denied You don't have permission to access "website" on this server.
该网站在我的常规chrome浏览器上可以正常运行,但是通过硒打开时,会收到此错误消息.
The website works fine on my regular chrome browser, but when opened through selenium I receive this error message.
我已经尝试了针对该错误的常规疑难解答,但没有帮助,我尝试安装firefox,但这又导致了另一个错误:消息:无法找到匹配的功能集"
I've tried the regular troubleshooting for the error but it didn't help, I've tried installing firefox but that resulted in another error: "Message: Unable to find a matching set of capabilities"
browser = webdriver.Chrome('C:\\Users\Ferdinand\Downloads\chromedriver_win32\chromedriver.exe')
browser.get('https://www.vitacost.com/MyAccount/Login.aspx')
我完全被困在这里,我在另一台计算机上尝试过,结果仍然相同.
I'm completely stuck here, I tried it another computer and still the same result.
推荐答案
如果您尝试使用 Headless 选项,我认为它可能与用户代理有关. 因为某些网站使用Headless阻止了用户代理.
If your trying has Headless option, I think it might be related to user-agent. Because some web site block the user-agent with Headless.
因此,请转到 https://www.whatsmyua.info/查找您的用户代理可以在您的普通chrome浏览器中使用,然后再试一次.
So, go to https://www.whatsmyua.info/ to find your user-agent which works in your regular chrome browser and try again with this.
ChromeOptions options = new ChromeOptions();
String userAget = "YOUR USER AGENT";
options.addArguments(String.format("user-agent=%s", userAgent));
这是一个Java代码,但我相信python中有完全相同的方法.
This is a java code but I believe there is an exactly same way in python.
这篇关于拒绝访问您无权访问“在服务器上使用ChromeDriver和Chrome通过Selenium Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!