Update nb4x.py
Browse files
nb4x.py
CHANGED
|
@@ -288,13 +288,9 @@ def single_registration():
|
|
| 288 |
chrome_options.add_argument('--disable-gpu')
|
| 289 |
chrome_options.add_argument('--headless=new')
|
| 290 |
|
| 291 |
-
# 添加
|
| 292 |
-
|
| 293 |
-
chrome_options.add_argument('--
|
| 294 |
-
|
| 295 |
-
# 确保 JavaScript 正常运行
|
| 296 |
-
chrome_options.add_argument('--enable-javascript')
|
| 297 |
-
chrome_options.add_argument('--disable-web-security')
|
| 298 |
|
| 299 |
# 其他优化选项
|
| 300 |
chrome_options.add_argument('--disable-blink-features=AutomationControlled')
|
|
@@ -302,11 +298,15 @@ def single_registration():
|
|
| 302 |
chrome_options.add_experimental_option('useAutomationExtension', False)
|
| 303 |
|
| 304 |
try:
|
| 305 |
-
# 直接使用系统安装的ChromeDriver
|
| 306 |
driver = webdriver.Chrome(options=chrome_options)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
wait = WebDriverWait(driver, 20)
|
| 308 |
-
|
| 309 |
success = registration_process(driver, wait)
|
|
|
|
| 310 |
if success:
|
| 311 |
logger.info("注册成功")
|
| 312 |
else:
|
|
@@ -333,7 +333,7 @@ def worker(thread_id):
|
|
| 333 |
logger.info(f"线程 {thread_id}: 本次循环成功")
|
| 334 |
else:
|
| 335 |
error_count += 1
|
| 336 |
-
logger.error(f"线程 {thread_id}: 本次循环失败,这
|
| 337 |
|
| 338 |
if error_count >= 5:
|
| 339 |
logger.critical(f"线程 {thread_id}: 续 {error_count} 次失败,出线程")
|
|
|
|
| 288 |
chrome_options.add_argument('--disable-gpu')
|
| 289 |
chrome_options.add_argument('--headless=new')
|
| 290 |
|
| 291 |
+
# 添加代理设置
|
| 292 |
+
proxy = "http://yvighdwv-1:a5fyzm76khsv@p.webshare.io:80"
|
| 293 |
+
chrome_options.add_argument(f'--proxy-server={proxy}')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
|
| 295 |
# 其他优化选项
|
| 296 |
chrome_options.add_argument('--disable-blink-features=AutomationControlled')
|
|
|
|
| 298 |
chrome_options.add_experimental_option('useAutomationExtension', False)
|
| 299 |
|
| 300 |
try:
|
|
|
|
| 301 |
driver = webdriver.Chrome(options=chrome_options)
|
| 302 |
+
|
| 303 |
+
# 验证代理是否工作
|
| 304 |
+
driver.get('https://api.ipify.org?format=json')
|
| 305 |
+
logger.info(f"当前IP: {driver.page_source}")
|
| 306 |
+
|
| 307 |
wait = WebDriverWait(driver, 20)
|
|
|
|
| 308 |
success = registration_process(driver, wait)
|
| 309 |
+
|
| 310 |
if success:
|
| 311 |
logger.info("注册成功")
|
| 312 |
else:
|
|
|
|
| 333 |
logger.info(f"线程 {thread_id}: 本次循环成功")
|
| 334 |
else:
|
| 335 |
error_count += 1
|
| 336 |
+
logger.error(f"线程 {thread_id}: 本次循环失败,这是第 {error_count} 次失败")
|
| 337 |
|
| 338 |
if error_count >= 5:
|
| 339 |
logger.critical(f"线程 {thread_id}: 续 {error_count} 次失败,出线程")
|