Though I knew people asked this question but I didn't find suitable answer so I asked again. I used PhantomJS to scrape web site, but it is very slow on Mac, so I want to tru Chrome but Chrome show browser that is is bad, can I hide it? I tried code as below, that still show a small browser window..
browser = webdriver.Chrome()
browser.set_window_position(0, 0)
browser.set_window_size(0, 0)
The answer is YES! Websites can detect the automation using JavaScript experimental technology navigator. webdriver in the navigator interface.
close() method is used to close the current browser window on which the focus is set, on the other hand quit() method essentially calls the driver.
ChromeDriver is a separate executable that Selenium WebDriver uses to control Chrome. It is maintained by the Chromium team with help from WebDriver contributors. If you are unfamiliar with Selenium WebDriver, you should check out the Selenium site.
Google announced in 4/2017 you can run in headless.
https://developers.google.com/web/updates/2017/04/headless-chrome
chrome_options = Options()
# Chrome v75 and lower:
# chrome_options.add_argument("--headless")
# Chrome v 76 and above (v76 released July 30th 2019):
chrome_options.headless = True
chrome_options.binary_location = '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary'
driver = webdriver.Chrome(executable_path=os.path.abspath(“chromedriver"), chrome_options=chrome_options)
Few things you should make sure
REF: how-could-i-start-a-selenium-browserlike-firefox-minimized
You can move browser window over the monitor, like this:
driver.set_window_position(-10000,0)
Try This!
https://beomi.github.io/2017/09/28/HowToMakeWebCrawler-Headless-Chrome/
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument('window-size=1920x1080')
options.add_argument("disable-gpu")
# OR options.add_argument("--disable-gpu")
driver = webdriver.Chrome('chromedriver', chrome_options=options)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With