Как играть в Musi c из безголового селена? - PullRequest
0 голосов
/ 13 января 2020

Я хотел создать приложение, которое воспроизводит Spotify Musi c в безголовом селене, но оно не воспроизводит песню вообще. Правильно ли работает скрипт для нажатия кнопки? Вот код

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
    executable_path = "chromedriver.exe"
    options = Options()
    options.add_argument('--no-sandbox')
    options.add_argument('--no-default-browser-check')
    options.add_argument('--disable-gpu')
    options.add_argument('--disable-extensions')
    options.add_argument('--disable-default-apps')
    options.add_argument('--headless')
    driver = webdriver.Chrome(executable_path=executable_path, options=options)
    driver.get('https://accounts.spotify.com/en/login?continue=https:%2F%2Fopen.spotify.com%2Falbum%2F0KXLHn67Go118RT48pTHXm')
    time.sleep(3)
    driver.find_element_by_name("username").send_keys('my email')
    driver.find_element_by_name("password").send_keys('my password')
    driver.find_element_by_xpath(('//*[@id="login-button"]')).send_keys(Keys.RETURN)
    time.sleep(3)
    driver.execute_script("arguments[0].click();", driver.find_element_by_css_selector('button.btn.btn-green.false'))

Когда я попытался запустить его, я получил это

[0113/001403.264:INFO:CONSOLE(0)] "Refused to load the image 'https://www.google.rs/ads/ga-audiences?v=1&aip=1&t=sr&_r=4&tid=UA-5784146-31&cid=434111290.1578870843&jid=1740149161&_v=j79&z=670730096&slf_rd=1&random=2105731225' because it violates the following Content Security Policy directive: "img-src 'self' https://i.imgur.com https://d2mv8tnci56s9d.cloudfront.net https://profile-images.scdn.co https://aci.scdn.co https://graph.facebook.com https://fbcdn-profile-a.akamaihd.net https://scontent.xx.fbcdn.net https://platform-lookaside.fbsbx.com https://www.google.com https://www.google-analytics.com https://stats.g.doubleclick.net data: https://accounts.scdn.co".
", source: https://accounts.spotify.com/en/login?continue=https:%2F%2Fopen.spotify.com%2Falbum%2F0KXLHn67Go118RT48pTHXm (0)
[0113/001407.421:INFO:CONSOLE(0)] "A cookie associated with a cross-site resource at http://google.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.", source: https://accounts.spotify.com/en/login?continue=https:%2F%2Fopen.spotify.com%2Falbum%2F0KXLHn67Go118RT48pTHXm (0)
[0113/001407.819:INFO:CONSOLE(0)] "A cookie associated with a cross-site resource at http://google.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.", source: https://open.spotify.com/album/0KXLHn67Go118RT48pTHXm (0)
[0113/001409.755:INFO:CONSOLE(0)] "A cookie associated with a cross-site resource at http://subscription.omnithrottle.com/ was set without the `SameSite` attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set with `SameSite=None` and `Secure`. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.", source: https://open.spotify.com/album/0KXLHn67Go118RT48pTHXm (0)
[0113/001410.001:INFO:CONSOLE(0)] "Uncaught (in promise) HarmonyError: Cannot perform command; local player is disabled.", source: https://open.spotify.com/album/0KXLHn67Go118RT48pTHXm (0) ```
...