Update nb4x.py
Browse files
nb4x.py
CHANGED
|
@@ -200,7 +200,7 @@ def registration_process(driver, wait):
|
|
| 200 |
|
| 201 |
time.sleep(0.5)
|
| 202 |
|
| 203 |
-
#
|
| 204 |
actions = webdriver.ActionChains(driver)
|
| 205 |
actions.send_keys(Keys.RETURN)
|
| 206 |
actions.perform()
|
|
@@ -245,13 +245,9 @@ 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 |
-
|
| 249 |
-
# 使用半无头模式
|
| 250 |
-
chrome_options.add_argument('--window-position=-32000,-32000') # 将窗口移到屏幕外
|
| 251 |
-
# chrome_options.add_argument('--headless=new') # 注释掉完全无头模式
|
| 252 |
|
| 253 |
# 其他优化选项
|
| 254 |
-
chrome_options.add_argument('--start-maximized')
|
| 255 |
chrome_options.add_argument('--disable-blink-features=AutomationControlled')
|
| 256 |
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
|
| 257 |
chrome_options.add_experimental_option('useAutomationExtension', False)
|
|
@@ -278,7 +274,7 @@ def worker(thread_id):
|
|
| 278 |
error_count = 0
|
| 279 |
while True:
|
| 280 |
try:
|
| 281 |
-
logger.info(f"线程 {thread_id}:
|
| 282 |
success = single_registration()
|
| 283 |
|
| 284 |
if success:
|
|
@@ -304,17 +300,8 @@ def worker(thread_id):
|
|
| 304 |
|
| 305 |
def main():
|
| 306 |
try:
|
| 307 |
-
#
|
| 308 |
-
|
| 309 |
-
try:
|
| 310 |
-
concurrent_num = int(input("请输入需要的并发数(1-10): "))
|
| 311 |
-
if 1 <= concurrent_num <= 10:
|
| 312 |
-
break
|
| 313 |
-
else:
|
| 314 |
-
print("请输入1-10之间的数字")
|
| 315 |
-
except ValueError:
|
| 316 |
-
print("请输入有效的数字")
|
| 317 |
-
|
| 318 |
logger.info(f"启动 {concurrent_num} 个并发线程")
|
| 319 |
|
| 320 |
# 创建线程池
|
|
|
|
| 200 |
|
| 201 |
time.sleep(0.5)
|
| 202 |
|
| 203 |
+
# 按回车继续
|
| 204 |
actions = webdriver.ActionChains(driver)
|
| 205 |
actions.send_keys(Keys.RETURN)
|
| 206 |
actions.perform()
|
|
|
|
| 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)
|
|
|
|
| 274 |
error_count = 0
|
| 275 |
while True:
|
| 276 |
try:
|
| 277 |
+
logger.info(f"线程 {thread_id}: 开始新的注册循环")
|
| 278 |
success = single_registration()
|
| 279 |
|
| 280 |
if success:
|
|
|
|
| 300 |
|
| 301 |
def main():
|
| 302 |
try:
|
| 303 |
+
# 设置固定的并发数为3
|
| 304 |
+
concurrent_num = 3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
logger.info(f"启动 {concurrent_num} 个并发线程")
|
| 306 |
|
| 307 |
# 创建线程池
|