简体   繁体   中英

Is there a way to use selenium with chrome and NOT chromedriver?

I am trying to automate a website that can detect chromedriver. I have used a user agent, I have gone in and changed the cdc_ part of the chromedriver, and several other things. No matter what I do it detects chromedriver and won't do anything.

However, I have been able to use Subprocesses and open my normal browser and sendkeys to go to the website, and do some of the things I need, so I know it will work in my normal browser.

Is there any way I can launch regular chrome and attach selenium to it in order to automate tasks?

Chromedriver drives chrome. It's not it's own browser.

Open chrome manually and go to chrome://version/

Then open your webdriver and go to the same link . You'll see that selenium is starting chrome on a new/temporary profile and enables a lot more arguments.

Just this line with no options driver = webdriver.Chrome() for me (in python) launches chrome with a long list of command line arguments: chrome selenium 命令行参数

You're most likely being detected because of the way selenium works.

This is a great post for detailing the problem and potential things to try: Can a website detect when you are using selenium with chromedriver?

Sites can detect some of the variables set by selenium.

@Erti-Chris Eelmaa put it really well:

the way the selenium detection works, is that they test for pre-defined javascript variables which appear when running with selenium. The bot detection scripts usually look anything containing word "selenium" / "webdriver" in any of the variables (on window object), and also document variables called $cdc_ and $wdc_. Of course, all of this depends on which browser you are on. All the different browsers expose different things.

You can disable javascript, and disable the "--enable-automation" through experimental tags but this can impact the functionality of selenium and your script might not work.

It might not be what you want to hear but when you're working on this (with selenium) keep in mind that the site is designed to stop automation so you're facing an uphill battle with it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM