ループ処理 変更
parent
ca54d390a4
commit
06f7198ed9
24
app/main.py
24
app/main.py
|
@ -104,22 +104,34 @@ def watching_rch():
|
|||
# 30秒待機
|
||||
time.sleep(30)
|
||||
|
||||
print( str( i + 1) + "番目のチャンネルの視聴を始めます。視聴時間は" + str(rch_time) + "秒に設定されています。")
|
||||
driver.save_screenshot('./ss/watching.png')
|
||||
print( "Rチャンネル:" + str( i + 1) + "番目のチャンネルの視聴を始めます。視聴時間は" + str(rch_time) + "秒に設定されています。")
|
||||
|
||||
try:
|
||||
channel_btns = driver.find_elements(By.CSS_SELECTOR, channel_btn_css)
|
||||
channel_btn = channel_btns[i]
|
||||
channel_btn.click()
|
||||
except:
|
||||
print("チャンネルが選択できませんでした。")
|
||||
driver.save_screenshot('./ss/error.png')
|
||||
print("Rチャンネル:チャンネルが選択できませんでした。")
|
||||
try:
|
||||
driver.save_screenshot('./ss/error.png')
|
||||
except:
|
||||
print("Rチャンネル:スクリーンショットの保存でエラーが発生しました。")
|
||||
|
||||
time.sleep(rch_time)
|
||||
|
||||
now_time = time.time()
|
||||
end_time = now_time + rch_time
|
||||
|
||||
while time.time() <= end_time:
|
||||
try:
|
||||
driver.save_screenshot('./ss/watching.png')
|
||||
except:
|
||||
print("Rチャンネル:スクリーンショットの保存でエラーが発生しました。")
|
||||
time.sleep(30)
|
||||
|
||||
try:
|
||||
driver.refresh()
|
||||
except:
|
||||
print("ページの更新に失敗しました。")
|
||||
print("Rチャンネル:ページの更新に失敗しました。")
|
||||
|
||||
driver.quit()
|
||||
|
||||
|
|
Loading…
Reference in New Issue