selenium added chrome configuration items

selenium powerful, but there are also inconvenient place, selenium every time you start the browser is an entirely new browser, and does not load any configuration, so that crawling a bit less convenient when some of the landing page to see the need . But we can load method chrome profiles, eliminating the need for repeated landing, but only one landed on the line.

0x01: access to personal data path

In the address bar, enter chrome chrome: // Version / , you can see information about chrome below. Among them the personal data path.



0x02: Setting Configuration Parameters

Park, for example by visiting the blog here, as follows:

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument(r'--user-data-dir=C:\Users\lwy\AppData\Local\Google\Chrome\User Data\Default')  # 设置个人资料路径
driver = webdriver.Chrome(options=options)


0x03: a manual landing

First visit, and I have not logged in before, and no user information to a manual landing, an automatic landing back on it.


 Did not show landing

0x04: automatic landing test

After the first landing manually, close the browser, run the code again, you can see that the automatic landing.



(Ps: chicken dish limited level, if the wrong place, at any time to correct me hope Gangster ... xixiixiix ..)

*************** short step a thousand miles. ***************

Guess you like