Pass the user-agent through webdriver in Selenium

后端 未结 2 619
感情败类
感情败类 2020-12-13 11:06

I am working on a website scraping project using Selenium in Python. When I open the homepage through a browser, it opens properly.

But, when I try to open the webpa

2条回答
  •  清歌不尽
    2020-12-13 12:10

    Assuming the user-agent is the problem, in Java you can modify it like this:

    FirefoxProfile profile = new FirefoxProfile();
    profile.addAdditionalPreference("general.useragent.override", "some UA string");
    WebDriver driver = new FirefoxDriver(profile);
    

    See documentation here.

提交回复
热议问题