質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

0回答

678閲覧

スクレイピングを毎日同じ時間に実行したい

TomF

総合スコア4

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2020/10/24 22:10

編集2020/10/24 22:21

スクレイピングを毎日同じ時刻に実行し、LINEで通知できるようにしたいです。
定時の処理、スクレイピング、LINE通知、それぞれの処理は実行できました。
しかし組み合わせると上手く実行できずエラーを吐いてしまいます。

python初学者なので分かりやすく解説いただけると幸いです。
よろしくお願いいたします。

###定時

python

1import datetime 2import schedule 3import time 4 5def job(): 6 print(datetime.datetime.now()) 7 print("I'm working...") 8 9schedule.every().day.at("14:25").do(job) 10 11while True: 12 schedule.run_pending() 13 time.sleep(60)

###スクレイピング

python

1from selenium import webdriver 2import chromedriver_binary 3from selenium.webdriver.common.by import By 4from selenium.webdriver.common.keys import Keys 5import time 6 7 8driver = webdriver.Chrome() 9driver.get('http://○○.jp/'); 10 11time.sleep(3) 12driver.find_element_by_css_selector("a.buttonMypagelogin").click() 13time.sleep(3) 14 15driver.find_element_by_xpath('//*[@id="loginInner_u"]').send_keys("○○○○") 16driver.find_element_by_xpath('//*[@id="loginInner_p"]').send_keys("○○○○") 17driver.find_element_by_css_selector("input.loginButton").click() 18time.sleep(3) 19driver.find_element_by_css_selector("span.balancedisplay_list_label").click() 20time.sleep(3) 21 22driver.get('http://○○○○'); 23driver.find_element_by_xpath('//*[@id="depositingInputPrice"]').send_keys("○○") 24driver.find_element_by_css_selector("span.confirm").click() 25time.sleep(3)

###LINE通知

python

1import requests 2 3def main(): 4 send_line_notify('Success') 5 6def send_line_notify(notification_message): 7 """ 8 LINEに通知する 9 """ 10 line_notify_token = '○○○○' 11 line_notify_api = 'https://notify-api.line.me/api/notify' 12 headers = {'Authorization': f'Bearer {line_notify_token}'} 13 data = {'message': f'message: {notification_message}'} 14 requests.post(line_notify_api, headers = headers, data = data) 15 16if __name__ == "__main__": 17 main()

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問