Automation Spotify使用Selenium、Python登录



我有一个语音助手。我想让它登录到我的Spotify帐户并播放一首歌。真正的问题是没有按钮的ID。所以我很难找到按钮并点击它们。

elif 'spotify' in query:
def spotify_login():
DRIVER = webdriver.Chrome(
executable_path='<EXECUTABLE_PATH>')
print('Searching for Login Button')
DRIVER.get('https://open.spotify.com/')
speak("Opened Spotify.")
DRIVER.maximize_window()
login_button = DRIVER.find_element_by_id('<id>')
login_button.click()
speak('Clicked On Login')
spotify_login()

这是代码。

您是否尝试过通过专用的spotify api实现自动化,例如"tekore";或";Spotipy":https://pypi.org/project/tekore/

https://github.com/plamere/spotipy

使用这两个api中的任何一个与Spotify网络应用程序交互可能会更容易,而不是尝试使用selenium来自动化过程。

login_button=WebDriverWait(驱动程序,10(.直到(EC.visibility_of_element_located((By.CSS_SELECTOR,"button[data-testid='login-ton']"()

点击登录按钮

login_button.click((

最新更新