Often when we scrape data or execute tasks on some platforms, we usually need to log in. When we build scripts, we encounter many errors that need to be fixed, which leads to a problem: every time we launch the browser, it opens a new browser window that is not logged in and has no traces. This is very troublesome because we have to log in again and again. With today's method, we can thoroughly learn how to solve this problem.
Commonly used libraries
```
import pandas as pd
import time
from DrissionPage import ChromiumPage, ChromiumOptions
from loguru import logger
import configparser
```
Steps
1. Write the Google Chrome path into the configuration file.
```
[配置]
浏览器路径=C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe
```
2. Create a Google Chrome shortcut in your project folder, then right-click it and open Properties. In the Target field, enter the following to enable the corresponding port and startup parameters:
```
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="D:/360MoveData/Users/Administrator/Desktop/DouyinCommenter/ChromeUserProfile" #替换这里的路径存放数据
```
3. Give this shortcut a new name.
4. Call it normally.
With the above parameter setup method, you can run the project in a fixed browser instead of opening a browser in the monitoring environment. |