You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Selenium访问Tidal被检测拦截且JavaScript不运行的解决咨询

解决方案

1. 屏蔽Selenium自动化特征

原生ChromeDriver存在大量可被反爬系统识别的特征标记,是本次拦截的核心原因之一,按如下规则调整启动参数:

  • 添加--disable-blink-features=AutomationControlled参数,移除浏览器内置的自动化控制标记
  • 排除enable-automation开关,禁用浏览器顶部的「Chrome正受到自动测试软件的控制」提示条
  • 关闭自动化扩展,修改webdriver相关的navigator属性,避免特征识别
  • 优先使用undetected-chromedriver,该工具对原生Chromedriver的特征做了批量擦除,适配绝大多数主流站点的反爬规则

2. 修复JavaScript运行异常问题

  • 禁止在启动参数中添加--disable-javascript配置,确保站点JS逻辑正常执行
  • 调整代理配置,避免代理节点拦截、篡改站点JS资源
  • 页面加载阶段添加显式等待,确保JS资源加载完成后再执行后续操作

3. 解决IP关联机器人问题

  • 更换为独享住宅代理,避免使用共享数据中心代理,这类代理的IP多数已经被站点标记为机器人IP
  • 每次启动访问前验证代理IP有效性,确认当前IP未被Tidal拉黑
  • 控制单IP的访问频率,避免短时间内高频请求触发阈值

4. 模拟正常用户行为

  • 页面跳转、操作之间添加随机时长的等待,避免固定间隔的机械操作
  • 若需要执行点击、输入等操作,模拟人类操作轨迹,不要直接调用元素定位接口执行操作
代码修改示例

原生Chrome参数优化版本

import time
import random
from selenium import webdriver
from selenium.webdriver.chrome.service import Service

proxies = proxy()
options = webdriver.ChromeOptions()
# 核心反检测参数
options.add_argument('--disable-blink-features=AutomationControlled')
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
# 代理配置
options.add_argument('--proxy-server=http://%s' % proxies)
options.binary_location = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"

driver = webdriver.Chrome(service=Service(r'C:/path/to/chromedriver.exe'), options=options)
# 擦除navigator.webdriver特征
driver.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {
    "source": """
        Object.defineProperty(navigator, 'webdriver', {
            get: () => undefined
        })
    """
})
driver.get("https://tidal.com/")
# 随机等待模拟正常用户停留
time.sleep(random.uniform(2,5))

undetected-chromedriver版本(更推荐)

首先安装依赖:pip install undetected-chromedriver

import time
import random
import undetected_chromedriver as uc

proxies = proxy()
options = uc.ChromeOptions()
options.add_argument('--proxy-server=http://%s' % proxies)
options.binary_location = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"

driver = uc.Chrome(executable_path=r'C:/path/to/chromedriver.exe', options=options)
driver.get("https://tidal.com/")
time.sleep(random.uniform(2,5))

内容的提问来源于stack exchange,提问作者kmays

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 09:36:04