Skip to content

Instantly share code, notes, and snippets.

@attakei
Last active July 11, 2020 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attakei/ad86791777c7b89d5f4308af4ceb7b94 to your computer and use it in GitHub Desktop.
Save attakei/ad86791777c7b89d5f4308af4ceb7b94 to your computer and use it in GitHub Desktop.
Using headless-chrome for MixBox

MixBoxをヘッドレスで呼ぶ

何をするもの?

7/10にバンダイナムコアーツがリリースした、サービスMixBoxをヘッドレスモードのGoogleChromeで呼びます。 再生開始まで行い、それ以上のことはしません。

MixBoxは こちら

必要なもの

  • Python
  • Google Chrome(あとでインストールするChromeDriverとバージョンを揃える)
  • run.py

作業

bash

$ pip install selenium chromedriver-binary $ python run.py

ライセンス

MIT

#!/usr/bin/env python
import time
from selenium import webdriver
class Mixbox:
def __init__(self):
options = webdriver.ChromeOptions()
options.add_argument("--headless")
driver = webdriver.Chrome(options=options)
driver.get("https://mixbox.live")
time.sleep(2)
self.driver = driver
def start(self, volume):
self.driver.find_element_by_id("button-play-initial").click()
def shutdown(self):
self.driver.quit()
if __name__ == "__main__":
mixbox = Mixbox()
try:
mixbox.start()
while True:
time.sleep(10)
except Exception as e:
print(e)
mixbox.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment