[PYTHON] [Automatic recording] Automatic continuous playback of Ito Juku streaming [Selenium]

Introduction

I don't like to consume giga when I want to watch Ito Juku streaming outside, so I wrote it for myself at once. I'm recording when I'm sleeping.

    1. Please reduce the streaming video size
  1. Please continue recording at the same position using recording software such as Bandicam. (The next video will be played in js with the same initial position and small size. All you have to do is fix the recording software and move it.) __3. Use it for yourself by the course purchaser. Streaming viewing rights are for the individual who purchased it. (Of course ...) __
  2. Please google for a detailed explanation of Selenium. If you can use F12 with Chrome, you can use it.

OS:Windows10 Google Chrome version: 85.0.4183.121 (Official Build) (64-bit) Python:3.70 Selenium Webdriver: Latest at the time of writing this article chromedriver.exe: latest at the time of writing this article

ringfit.py



from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import time

opt = webdriver.ChromeOptions()
#opt.add_argument('--blink-settings=imagesEnabled=false')
browser = webdriver.Chrome(options=opt)

browser.get('https://www.itojuku.co.jp/index.html')

elem_mypage = browser.find_element_by_xpath('//*[@id="bk814"]/div/div/div[2]/div/span/a').click()
time.sleep(3)

elem_email = browser.find_element_by_name('login_email')
elem_email.send_keys('your_email')
elem_password = browser.find_element_by_name('login_pass')
elem_password.send_keys('your_password')
elem_login_btn = browser.find_element_by_id('log').click()

time.sleep(5)

elem_kouza_btn = browser.find_element_by_id('gnavi__jukou').click()
elem_juko_btn = browser.find_element_by_xpath('//*[@id="gnavi__jukou"]/div/div/div[1]/a').click()

WebDriverWait(browser, 3).until(lambda d: len(d.window_handles) > 1)
browser.switch_to.window(browser.window_handles[1])

#Change part 1
#Please change the course you want to record the characters here.
#This is a manual change, as recordings that long are not possible anyway.
elem_kiso_minpo = browser.find_element_by_link_text('20 Basic Power Completion Master Civil Code [Hirabayashi]').click()
#find_element(:partial_link_text, "Login").click

time.sleep(1)
#Change part 2
#Please match the name of img here to the course you want to record.
elem_detail = browser.find_element_by_name('Image00049510').click()
time.sleep(1)
#Change part 3
#Since the name name of img is basically a serial number, every 3600 seconds (1 hour)+It is shaped like a loop.
for num in range(59, 81):
    image_num = 'Image000000' + str(num)
    time.sleep(1)
    elem_minpo_kiso_kougi_btn =  browser.find_element_by_name(image_num).click()
    time.sleep(1)
    elem_minpo_kiso_kougi_btn =  browser.find_element_by_xpath('/html/body/table/tbody/tr[2]/td[2]/table[3]/tbody/tr/td[3]/p/a/img').click()
#1 hour recording
    time.sleep(3600)
    elem_modoru = browser.find_element_by_link_text('≪To category selection').click()

伊藤塾自動録画.png

Recommended Posts

[Automatic recording] Automatic continuous playback of Ito Juku streaming [Selenium]
Automatic operation of Chrome with Python + Selenium + pandas