Update nb4x.py
Browse files
nb4x.py
CHANGED
|
@@ -245,19 +245,18 @@ def single_registration():
|
|
| 245 |
chrome_options.add_argument('--no-sandbox')
|
| 246 |
chrome_options.add_argument('--disable-dev-shm-usage')
|
| 247 |
chrome_options.add_argument('--disable-gpu')
|
| 248 |
-
chrome_options.add_argument('--headless=new')
|
| 249 |
|
| 250 |
# 其他优化选项
|
| 251 |
chrome_options.add_argument('--disable-blink-features=AutomationControlled')
|
| 252 |
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
|
| 253 |
chrome_options.add_experimental_option('useAutomationExtension', False)
|
| 254 |
|
| 255 |
-
# 创建ChromeDriver服务和实例
|
| 256 |
-
service = Service(ChromeDriverManager().install())
|
| 257 |
-
driver = webdriver.Chrome(service=service, options=chrome_options)
|
| 258 |
-
wait = WebDriverWait(driver, 20)
|
| 259 |
-
|
| 260 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
success = registration_process(driver, wait)
|
| 262 |
if success:
|
| 263 |
logger.info("注册成功")
|
|
@@ -268,7 +267,10 @@ def single_registration():
|
|
| 268 |
logger.error(f"注册过程发生错误: {str(e)}")
|
| 269 |
return False
|
| 270 |
finally:
|
| 271 |
-
|
|
|
|
|
|
|
|
|
|
| 272 |
|
| 273 |
def worker(thread_id):
|
| 274 |
error_count = 0
|
|
|
|
| 245 |
chrome_options.add_argument('--no-sandbox')
|
| 246 |
chrome_options.add_argument('--disable-dev-shm-usage')
|
| 247 |
chrome_options.add_argument('--disable-gpu')
|
| 248 |
+
chrome_options.add_argument('--headless=new')
|
| 249 |
|
| 250 |
# 其他优化选项
|
| 251 |
chrome_options.add_argument('--disable-blink-features=AutomationControlled')
|
| 252 |
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
|
| 253 |
chrome_options.add_experimental_option('useAutomationExtension', False)
|
| 254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
try:
|
| 256 |
+
# 直接使用系统安装的ChromeDriver
|
| 257 |
+
driver = webdriver.Chrome(options=chrome_options)
|
| 258 |
+
wait = WebDriverWait(driver, 20)
|
| 259 |
+
|
| 260 |
success = registration_process(driver, wait)
|
| 261 |
if success:
|
| 262 |
logger.info("注册成功")
|
|
|
|
| 267 |
logger.error(f"注册过程发生错误: {str(e)}")
|
| 268 |
return False
|
| 269 |
finally:
|
| 270 |
+
try:
|
| 271 |
+
driver.quit()
|
| 272 |
+
except:
|
| 273 |
+
pass
|
| 274 |
|
| 275 |
def worker(thread_id):
|
| 276 |
error_count = 0
|