[PYTHON] Workaround for Chrome headless mode error

Introduction

After creating a scraping tool with python, an error occurred when I started it on another network. (Headless mode is an error, browser startup mode is normal) The measures to be taken at that time are described.

The error occurred due to the PROXY server

When creating the tool, the connection to the Internet was directly from WiFi (probably), the place where the tool was moved was a terminal connected to the company network, and the PROXY server was set.

Checking the PROXY server from the terminal

WINDOWS10 "Settings"-> "Proxy"-> "Use proxy server" is "On". Make a note of the address. MAC "System Preferences"-> "Network"-> "Details"-> "Proxy"-> "Web Proxy (HTTP)" is checked. Make a note of the "Web Proxy Server" address.

Add code

python


option.add_argument('--headless')	                  #← Headless mode is specified
option.add_argument('--proxy-server=http://※※※')   #Add this!

※※※ is the address you wrote down

Recommended Posts

Workaround for Chrome headless mode error
[Python] for statement error
Tips for using Selenium and Headless Chrome in a CUI environment